MediaManager

public classMediaManagerextendsObject

Manager class for all media status and commands.

This class is responsible to translate media namespace messages from senders into media commands, and send media status back to the sender.

Nested Class Summary

interface MediaManager.MediaStatusInterceptor Interceptor interface for MediaStatus.

Public Method Summary

void
broadcastMediaStatus()
Trigger a media status broadcast.
MediaStatus
getBaseMediaStatus()
Returns the baseMediaStatus which is generated from Android MediaSession, before applying any overrides from MediaStatusModifier, MediaQueueManageror MediaManager.MediaStatusInterceptor.
MediaStatus
getCurrentMediaStatus()
Returns the currentMediaStatus generated from the baseMediaStatus with overrides applied from MediaStatusModifierand MediaQueueManager(note that changes from MediaManager.MediaStatusInterceptoris not applied).
MediaQueueManager
MediaStatusModifier
boolean
onNewIntent(Intent intent)
Passes a new activity intent toMediaManager.
void
setDataFromLoad(MediaLoadRequestData loadRequestData)
Initializes MediaStatusModifierand MediaQueueManageroverrides using the information from a load request.
void
void
setMediaLoadCommandCallback(MediaLoadCommandCallback callback)
Sets the MediaLoadCommandCallbackto handle load and resume session requests.
void
setMediaStatusInterceptor(MediaManager.MediaStatusInterceptor interceptor)
Sets the MediaManager.MediaStatusInterceptorto intercept and modify the MediaStatus before it is being sent out.
void
setSessionCompatToken(MediaSessionCompat.Token token)
Sets and attaches to a MediaSession token.

Inherited Method Summary

Public Methods

public voidbroadcastMediaStatus()

Trigger a media status broadcast.

The broadcastedMediaStatus is generated in the following steps:

  1. The library generates the baseMediaStatus based on the current MediaSessionCompatinformation.
  2. The library applies the overrides fromMediaStatusModifier andMediaQueueManager.
  3. The library invokes the MediaManager.MediaStatusInterceptorto apply final changes to the MediaStatus.
  4. Send theMediaStatus to the senders.

publicMediaStatus getBaseMediaStatus()

Returns the baseMediaStatus which is generated from Android MediaSession, before applying any overrides from MediaStatusModifier, MediaQueueManager or MediaManager.MediaStatusInterceptor.

Returnsnullif no MediaSession attached or no metadata or playback state from MediaSession.

The following common commands are always added to the baseMediaStatus by default (You can still override these commands via theMediaStatusModifier):

publicMediaStatus getCurrentMediaStatus()

Returns the currentMediaStatus generated from the baseMediaStatus with overrides applied fromMediaStatusModifier andMediaQueueManager (note that changes from MediaManager.MediaStatusInterceptoris not applied).

Returnsnullif no MediaSession attached or no metadata or playback state from MediaSession.

publicMediaQueueManager getMediaQueueManager()

Returns theMediaQueueManager.

SeeMediaQueueManager for details about the queue manager.

See broadcastMediaStatus()for howMediaStatus is processed.

publicMediaStatusModifier getMediaStatusModifier()

Returns theMediaStatusModifier.

SeeMediaStatusModifier for details about the modifier.

See broadcastMediaStatus()for howMediaStatus is processed.

public booleanonNewIntent(Intent intent)

Passes a new activity intent toMediaManager. If it is a supported load or resume session intent, it will be notified via callbacks inMediaCommandCallback.

Returns
  • trueif the intent is handled by the SDK

public voidsetDataFromLoad(MediaLoadRequestData loadRequestData)

InitializesMediaStatusModifier andMediaQueueManager overrides using the information from a load request.

All current overrides inMediaStatusModifier andMediaQueueManager will be cleared after this method call.

See MediaStatusModifier.clear()about clearing overrides inMediaStatusModifier.

See MediaQueueManager.clear()about clearing overrides inMediaQueueManager.

See MediaQueueManager.autoGenerateItemId()about auto-generation of item IDs.

public voidsetMediaCommandCallback(MediaCommandCallback callback)

Sets theMediaCommandCallback. Setting tonullresets to the default implementation.

The default implementation translates cast commands into MediaControllerCompat.TransportControlscommands.

public voidsetMediaLoadCommandCallback(MediaLoadCommandCallback callback)

Sets the MediaLoadCommandCallbackto handle load and resume session requests. Setting tonullresets the default implementation.

The default implementation fails all requests.

public voidsetMediaStatusInterceptor(MediaManager.MediaStatusInterceptor interceptor)

Sets the MediaManager.MediaStatusInterceptorto intercept and modify the MediaStatus before it is being sent out.

The interceptor operates on aMediaStatus after applying overrides fromMediaStatusModifier andMediaQueueManager.

public voidsetSessionCompatToken(MediaSessionCompat.Token token)

Sets and attaches to a MediaSession token. Setting tonulldetaches the library from the current MediaSession token.