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
Inherited Method Summary
Public Methods
public void broadcastMediaStatus ()
Trigger a media status broadcast.
The broadcasted MediaStatus
is generated in the following steps:
- The library generates the base
MediaStatus
based on the currentMediaSessionCompat
information. - The library applies the overrides from
MediaStatusModifier
andMediaQueueManager
. - The library invokes the
MediaManager.MediaStatusInterceptor
to apply final changes to theMediaStatus
. - Send the
MediaStatus
to the senders.
public MediaStatus getBaseMediaStatus ()
Returns the base MediaStatus
which is generated from Android MediaSession, before applying any overrides from
MediaStatusModifier
,
MediaQueueManager
or
MediaManager.MediaStatusInterceptor
.
Returns null
if no MediaSession attached or no metadata or playback
state from MediaSession.
The following common commands are always added to the base MediaStatus
by default (You can still override these commands via the MediaStatusModifier
):
public MediaStatus getCurrentMediaStatus ()
Returns the current MediaStatus
generated from the base MediaStatus
with overrides applied from MediaStatusModifier
and MediaQueueManager
(note that changes from
MediaManager.MediaStatusInterceptor
is not applied).
Returns null
if no MediaSession attached or no metadata or playback
state from MediaSession.
public MediaQueueManager getMediaQueueManager ()
Returns the MediaQueueManager
.
See MediaQueueManager
for details about the queue manager.
See
broadcastMediaStatus()
for how MediaStatus
is processed.
public MediaStatusModifier getMediaStatusModifier ()
Returns the MediaStatusModifier
.
See MediaStatusModifier
for details about the modifier.
See
broadcastMediaStatus()
for how MediaStatus
is processed.
public boolean onNewIntent (Intent intent)
Passes a new activity intent to MediaManager
.
If it is a supported load or resume session intent, it will be notified via callbacks
in MediaCommandCallback
.
Returns
true
if the intent is handled by the SDK
public void setDataFromLoad (MediaLoadRequestData loadRequestData)
Initializes MediaStatusModifier
and MediaQueueManager
overrides using the information from a load request.
All current overrides in MediaStatusModifier
and MediaQueueManager
will be cleared after this method call.
MediaStatusModifier
will set theMediaInfo
and tracks information from the load request.MediaQueueManager
will set the queue items, queue status, etc. from the load request. Note thatMediaQueueManager
will automatically assign item IDs to the queue items. The auto-assignment is internally done by callingMediaQueueManager.autoGenerateItemId()
. You can also opt-out by assigning item IDs by yourself. This can be done by usingMediaQueueItemWriter
to modify the queue items obtained fromMediaQueueManager.getQueueItems()
.
MediaStatusModifier.clear()
about clearing overrides in MediaStatusModifier
.
See
MediaQueueManager.clear()
about clearing overrides in MediaQueueManager
.
See
MediaQueueManager.autoGenerateItemId()
about auto-generation of item
IDs.
public void setMediaCommandCallback (MediaCommandCallback callback)
Sets the MediaCommandCallback
.
Setting to null
resets to the default implementation.
The default implementation translates cast commands into
MediaControllerCompat.TransportControls
commands.
public void setMediaLoadCommandCallback (MediaLoadCommandCallback callback)
Sets the
MediaLoadCommandCallback
to handle load and resume session requests. Setting
to null
resets the default implementation.
The default implementation fails all requests.
public void setMediaStatusInterceptor (MediaManager.MediaStatusInterceptor interceptor)
Sets the
MediaManager.MediaStatusInterceptor
to intercept and modify the
MediaStatus
before it is being sent out.
The interceptor operates on a MediaStatus
after applying overrides from MediaStatusModifier
and MediaQueueManager
.
public void setSessionCompatToken (MediaSessionCompat.Token token)
Sets and attaches to a MediaSession token. Setting to null
detaches the
library from the current MediaSession token.