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 voidbroadcastMediaStatus()
Trigger a media status broadcast.
The broadcastedMediaStatus
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.
publicMediaStatus getBaseMediaStatus()
Returns the baseMediaStatus
which is generated from Android MediaSession, before applying any overrides from
MediaStatusModifier
,
MediaQueueManager
or
MediaManager.MediaStatusInterceptor
.
Returnsnull
if 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.MediaStatusInterceptor
is not applied).
Returnsnull
if 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
true
if 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.
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 inMediaStatusModifier
.
See
MediaQueueManager.clear()
about clearing overrides inMediaQueueManager
.
See
MediaQueueManager.autoGenerateItemId()
about auto-generation of item
IDs.
public voidsetMediaCommandCallback(MediaCommandCallback callback)
Sets theMediaCommandCallback
.
Setting tonull
resets to the default implementation.
The default implementation translates cast commands into
MediaControllerCompat.TransportControls
commands.
public voidsetMediaLoadCommandCallback(MediaLoadCommandCallback callback)
Sets the
MediaLoadCommandCallback
to handle load and resume session requests. Setting
tonull
resets the default implementation.
The default implementation fails all requests.
public voidsetMediaStatusInterceptor(MediaManager.MediaStatusInterceptor interceptor)
Sets the
MediaManager.MediaStatusInterceptor
to 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 tonull
detaches the
library from the current MediaSession token.