Skip to content

features/nowPlaying ​

useNowPlaying() ​

ts
function useNowPlaying(): 
  | NowPlayingMetadata
  | undefined;

Hook that returns the current now playing metadata and updates when it changes.

Returns ​

| NowPlayingMetadata | undefined

The current now playing metadata or undefined


getNowPlaying() ​

ts
function getNowPlaying(): 
  | NowPlayingMetadata
  | undefined;

Gets the current now playing metadata (override if set, else track metadata).

Returns ​

| NowPlayingMetadata | undefined


updateNowPlaying() ​

ts
function updateNowPlaying(update): void;

Updates the now playing notification metadata. Pass null/undefined to clear overrides and revert to track metadata.

Parameters ​

ParameterType
updateNowPlayingUpdate | null

Returns ​

void

Example ​

ts
// Override notification with stream metadata
updateNowPlaying({
  title: streamMetadata.title,
  artist: streamMetadata.artist,
})

// Clear overrides, revert to track metadata
updateNowPlaying(null)

onNowPlayingChanged ​

ts
const onNowPlayingChanged: NativeUpdatedValue<NowPlayingMetadata>;

Subscribes to now playing metadata change events. Fires when updateNowPlaying is called or when the track changes.

Param ​

Called when now playing metadata changes

Returns ​

Cleanup function to unsubscribe