RemotePlaybackClient

public class RemotePlaybackClient
extends Object

java.lang.Object
   ↳ androidx.mediarouter.media.RemotePlaybackClient


A helper class for playing media on remote routes using the remote playback protocol defined by MediaControlIntent.

The client maintains session state and offers a simplified interface for issuing remote playback media control intents to a single route.

Summary

Nested classes

class RemotePlaybackClient.ActionCallback

Base callback type for remote playback requests. 

class RemotePlaybackClient.ItemActionCallback

Callback for remote playback requests that operate on items. 

interface RemotePlaybackClient.OnMessageReceivedListener

A callback that will receive messages from media sessions. 

class RemotePlaybackClient.SessionActionCallback

Callback for remote playback requests that operate on sessions. 

class RemotePlaybackClient.StatusCallback

A callback that will receive media status updates. 

Public constructors

RemotePlaybackClient(Context context, MediaRouter.RouteInfo route)

Creates a remote playback client for a route.

<

Public methods

void endSession(Bundle extras, RemotePlaybackClient.SessionActionCallback callback)

Sends a request to end the media playback session.

void enqueue(Uri contentUri, String mimeType, Bundle metadata, long positionMillis, Bundle extras, RemotePlaybackClient.ItemActionCallback callback)

Sends a request to enqueue a media item.

String getSessionId()

Gets the current session id if there is one.

void getSessionStatus(Bundle extras, RemotePlaybackClient.SessionActionCallback callback)

Sends a request to get the status of the media playback session.

void getStatus(String itemId, Bundle extras, RemotePlaybackClient.ItemActionCallback callback)

Sends a request to get the status of a media item.

boolean hasSession()

Returns true if the client currently has a session.

boolean isMessagingSupported()

Returns true if the route supports messages.

boolean isQueuingSupported()

Returns true if the route supports queuing features.

boolean isRemotePlaybackSupported()

Returns true if the route supports remote playback.

boolean isSessionManagementSupported()

Returns true if the route supports session management features.

void pause(Bundle extras, RemotePlaybackClient.SessionActionCallback callback)

Sends a request to pause media playback.

void play(Uri contentUri, String mimeType, Bundle metadata, long positionMillis, Bundle extras, RemotePlaybackClient.ItemActionCallback callback)

Sends a request to play a media item.

void release()

Releases resources owned by the client.

void remove(String itemId, Bundle extras, RemotePlaybackClient.ItemActionCallback callback)

Sends a request to remove a media item from the queue.

void resume(Bundle extras, RemotePlaybackClient.SessionActionCallback callback)

Sends a request to resume (unpause) media playback.

void seek(String itemId, long positionMillis, Bundle extras, RemotePlaybackClient.ItemActionCallback callback)

Sends a request to seek to a new position in a media item.

void sendMessage(Bundle message, RemotePlaybackClient.SessionActionCallback callback)

Sends a message.

void setOnMessageReceivedListener(RemotePlaybackClient.OnMessageReceivedListener listener)

Sets a callback that should receive messages when a message is sent from media sessions created by this instance of the remote playback client changes.

void setSessionId(String sessionId)

Sets the current session id.

void setStatusCallback(RemotePlaybackClient.StatusCallback callback)

Sets a callback that should receive status updates when the state of media sessions or media items created by this instance of the remote playback client changes.

void startSession(Bundle extras, RemotePlaybackClient.SessionActionCallback callback)

Sends a request to start a new media playback session.

void stop(Bundle extras, RemotePlaybackClient.SessionActionCallback callback)

Sends a request to stop media playback and clear the media playback queue.