RemoteMediaPlayer

public classRemoteMediaPlayerextendsObject
implementsMessageReceivedCallback

This class is deprecated.
SeeMigrate Android Sender App from Cast SDK v2 to v3.

Class for controlling a media player application running on a receiver.

Some operations, like loading of media or adjusting volume, can be tracked. The corresponding methods return aPendingResult for this purpose.

Any media session created by calling load(GoogleApiClient, MediaInfo)or queueLoad(GoogleApiClient, MediaQueueItem[], int, int, long, JSONObject)will be associated with a queue on the receiver application. If the media session is created by calling load(GoogleApiClient, MediaInfo),then the media queue is a non-repeatable queue with a single item, and other queuing related operations such as queueInsertItems(GoogleApiClient, MediaQueueItem[], int, JSONObject)and queueUpdateItems(GoogleApiClient, MediaQueueItem[], JSONObject)can still be applied on top of it.

Nested Class Summary

interface RemoteMediaPlayer.MediaChannelResult This interface is deprecated. SeeMigrate Android Sender App from Cast SDK v2 to v3.
interface RemoteMediaPlayer.OnMetadataUpdatedListener This interface is deprecated. SeeMigrate Android Sender App from Cast SDK v2 to v3.
interface RemoteMediaPlayer.OnPreloadStatusUpdatedListener This interface is deprecated. SeeMigrate Android Sender App from Cast SDK v2 to v3.
interface RemoteMediaPlayer.OnQueueStatusUpdatedListener This interface is deprecated. SeeMigrate Android Sender App from Cast SDK v2 to v3.
interface RemoteMediaPlayer.OnStatusUpdatedListener This interface is deprecated. SeeMigrate Android Sender App from Cast SDK v2 to v3.

Constant Summary

int RESUME_STATE_PAUSE A resume state indicating that the player should be paused, regardless of its current state.
int RESUME_STATE_PLAY A resume state indicating that the player should be playing, regardless of its current state.
int RESUME_STATE_UNCHANGED A resume state indicating that the player state should be left unchanged.
int STATUS_CANCELED A status indicating that a request was canceled.
int STATUS_FAILED A status indicating that a request failed.
int STATUS_REPLACED A status indicating that the request's progress is no longer being tracked because another request of the same type has been made before the first request completed.
int STATUS_SUCCEEDED A status indicating that a request completed successfully.
int STATUS_TIMED_OUT A status indicating that a request has timed out.

Field Summary

public static finalString NAMESPACE Returns the namespace used by theRemoteMediaPlayer to send media commands.

Public Constructor Summary

Public Method Summary

long
getApproximateStreamPosition()
Returns the approximate stream position as calculated from the last received stream information and the elapsed wall-time since that update.
MediaInfo
getMediaInfo()
Returns the current media information, if any.
MediaStatus
getMediaStatus()
Returns the current media status, if any.
String
getNamespace()
Returns the media control namespace.
long
getStreamDuration()
Convenience method for getting the stream duration.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
load(GoogleApiClient apiClient,MediaInfo mediaInfo, boolean autoplay, long playPosition,JSONObject customData)
Loads and optionally starts playback of a new media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
load(GoogleApiClient apiClient,MediaInfo mediaInfo, boolean autoplay, long playPosition)
Loads and optionally starts playback of a new media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
load(GoogleApiClient apiClient,MediaInfo mediaInfo)
Loads and automatically starts playback of a new media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
load(GoogleApiClient apiClient,MediaInfo mediaInfo, boolean autoplay)
Loads and optionally starts playback of a new media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
load(GoogleApiClient apiClient,MediaInfo mediaInfo, boolean autoplay, long playPosition, long[] activeTrackIds,JSONObject customData)
Loads and optionally starts playback of a new media item.
void
onMessageReceived(CastDevice castDevice,Stringnamespace, String message)
Called when a message is received from a givenCastDevice.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
pause(GoogleApiClient apiClient)
Pauses playback of the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
pause(GoogleApiClient apiClient,JSONObject customData)
Pauses playback of the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
play(GoogleApiClient apiClient,JSONObject customData)
Begins (or resumes) playback of the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
play(GoogleApiClient apiClient)
Begins (or resumes) playback of the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueAppendItem(GoogleApiClient apiClient,MediaQueueItem item,JSONObject customData)
Appends a new media item to the end of the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueInsertAndPlayItem(GoogleApiClient apiClient,MediaQueueItem item, int insertBeforeItemId, long playPosition,JSONObject customData)
A convenience method that inserts a single item into the queue and starts playing it at the specified position.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueInsertAndPlayItem(GoogleApiClient apiClient,MediaQueueItem item, int insertBeforeItemId,JSONObject customData)
A convenience method that inserts a single item into the queue and starts playing it.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueInsertItems(GoogleApiClient apiClient,MediaQueueItem[] itemsToInsert, int insertBeforeItemId,JSONObject customData)
Inserts a list of new media items into the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueJumpToItem(GoogleApiClient apiClient, int itemId,JSONObject customData)
Plays the item withitemIdin the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueJumpToItem(GoogleApiClient apiClient, int itemId, long playPosition,JSONObject customData)
Plays the item withitemIdin the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueLoad(GoogleApiClient apiClient,MediaQueueItem[] items, int startIndex, int repeatMode, long playPosition,JSONObject customData)
Loads and optionally starts playback of a new queue of media items.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueLoad(GoogleApiClient apiClient,MediaQueueItem[] items, int startIndex, int repeatMode,JSONObject customData)
Loads and optionally starts playback of a new queue of media items.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueMoveItemToNewIndex(GoogleApiClient apiClient, int itemId, int newIndex,JSONObject customData)
Moves the item withitemIdto a new position in the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueNext(GoogleApiClient apiClient,JSONObject customData)
Jumps to the next item in the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queuePrev(GoogleApiClient apiClient,JSONObject customData)
Jumps to the previous item in the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueRemoveItem(GoogleApiClient apiClient, int itemId,JSONObject customData)
Removes the item withitemIdfrom the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueRemoveItems(GoogleApiClient apiClient, int[] itemIdsToRemove,JSONObject customData)
Removes a list of items from the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueReorderItems(GoogleApiClient apiClient, int[] itemIdsToReorder, int insertBeforeItemId,JSONObject customData)
Reorder a list of media items in the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueSetRepeatMode(GoogleApiClient apiClient, int repeatMode,JSONObject customData)
Sets the repeat mode of the queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
queueUpdateItems(GoogleApiClient apiClient,MediaQueueItem[] itemsToUpdate,JSONObject customData)
Updates properties of a subset of the existing items in the media queue.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
requestStatus(GoogleApiClient apiClient)
Requests updated media status information from the receiver.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
seek(GoogleApiClient apiClient, long position)
Seeks to a new position within the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
seek(GoogleApiClient apiClient, long position, int resumeState,JSONObject customData)
Seeks to a new position within the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
seek(GoogleApiClient apiClient, long position, int resumeState)
Seeks to a new position within the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
setActiveMediaTracks(GoogleApiClient apiClient, long[] trackIds)
Sets the active media tracks.
void
void
void
void
PendingResult<RemoteMediaPlayer.MediaChannelResult>
setStreamMute(GoogleApiClient apiClient, boolean muteState,JSONObject customData)
Toggles the stream muting.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
setStreamMute(GoogleApiClient apiClient, boolean muteState)
Toggles the stream muting.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
setStreamVolume(GoogleApiClient apiClient, double volume,JSONObject customData)
Sets the stream volume.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
setStreamVolume(GoogleApiClient apiClient, double volume)
Sets the stream volume of the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
setTextTrackStyle(GoogleApiClient apiClient,TextTrackStyle trackStyle)
Sets the text track style.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
stop(GoogleApiClient apiClient,JSONObject customData)
Stops playback of the current media item.
PendingResult<RemoteMediaPlayer.MediaChannelResult>
stop(GoogleApiClient apiClient)
Stops playback of the current media item.

Inherited Method Summary

Constants

public static final int RESUME_STATE_PAUSE

A resume state indicating that the player should be paused, regardless of its current state.

Constant Value:2

public static final int RESUME_STATE_PLAY

A resume state indicating that the player should be playing, regardless of its current state.

Constant Value:1

public static final int RESUME_STATE_UNCHANGED

A resume state indicating that the player state should be left unchanged.

Constant Value:0

public static final int STATUS_CANCELED

A status indicating that a request was canceled.

Constant Value:2101

public static final int STATUS_FAILED

A status indicating that a request failed. Equivalent toCastStatusCodes.FAILED.

Constant Value:2100

public static final int STATUS_REPLACED

A status indicating that the request's progress is no longer being tracked because another request of the same type has been made before the first request completed. This applies to requests such as volume change, where a new request invalidates the results of a previous one. Equivalent toCastStatusCodes.REPLACED.

Constant Value:2103

public static final int STATUS_SUCCEEDED

A status indicating that a request completed successfully. Equivalent to CastStatusCodes.SUCCESS.

Constant Value:0

public static final int STATUS_TIMED_OUT

A status indicating that a request has timed out.

Constant Value:2102

Fields

public static finalString NAMESPACE

Returns the namespace used by theRemoteMediaPlayer to send media commands.

Public Constructors

publicRemoteMediaPlayer()

The constructor ofRemoteMediaPlayer.

Public Methods

public longgetApproximateStreamPosition()

Returns the approximate stream position as calculated from the last received stream information and the elapsed wall-time since that update.

Returns
  • The approximate stream position, in milliseconds.

publicMediaInfo getMediaInfo()

Returns the current media information, if any.

publicMediaStatus getMediaStatus()

Returns the current media status, if any.

publicStringgetNamespace()

Returns the media control namespace.

public longgetStreamDuration()

Convenience method for getting the stream duration.

Returns
  • The stream duration, in milliseconds.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> load(GoogleApiClient apiClient,MediaInfomediaInfo, boolean autoplay, long playPosition,JSONObject customData)

Loads and optionally starts playback of a new media item. The media item starts playback atplayPosition.This method optionally sends custom data as a JSONObjectwith the load request.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
mediaInfo An object describing the media item to load. Must not be null.
autoplay Whether playback should start immediately.
playPosition The initial playback position, in milliseconds from the beginning of the stream.
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> load(GoogleApiClient apiClient,MediaInfomediaInfo, boolean autoplay, long playPosition)

Loads and optionally starts playback of a new media item. The media item starts playback atplayPosition.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
mediaInfo An object describing the media item to load. Must not be null.
autoplay Whether playback should start immediately.
playPosition The initial playback position, in milliseconds from the beginning of the stream.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> load(GoogleApiClient apiClient,MediaInfo mediaInfo)

Loads and automatically starts playback of a new media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
mediaInfo An object describing the media item to load. Must not be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> load(GoogleApiClient apiClient,MediaInfomediaInfo, boolean autoplay)

Loads and optionally starts playback of a new media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
mediaInfo An object describing the media item to load. Must not be null.
autoplay Whether playback should start immediately.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> load(GoogleApiClient apiClient,MediaInfomediaInfo, boolean autoplay, long playPosition, long[] activeTrackIds,JSONObject customData)

Loads and optionally starts playback of a new media item. The media item starts playback atplayPosition.This method optionally sends custom data as a JSONObjectwith the load request. Also, it optionally sends an array of track IDs that should be active. If the array is not provided, the default tracks will be used.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
mediaInfo An object describing the media item to load. Must not be null.
autoplay Whether playback should start immediately.
playPosition The initial playback position, in milliseconds from the beginning of the stream.
activeTrackIds The list of track IDs to use when loading the media, may be null.
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.

public voidonMessageReceived(CastDevicecastDevice, Stringnamespace, String message)

Called when a message is received from a givenCastDevice. This method is called on the main thread.

Parameters
castDevice The castDevice from whence the message originated.
namespace The namespace of the received message.
message The received payload for the message.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> pause(GoogleApiClient apiClient)

Pauses playback of the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> pause(GoogleApiClient apiClient,JSONObject customData)

Pauses playback of the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> play(GoogleApiClient apiClient,JSONObject customData)

Begins (or resumes) playback of the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> play(GoogleApiClient apiClient)

Begins (or resumes) playback of the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueAppendItem(GoogleApiClient apiClient,MediaQueueItem item,JSONObject customData)

Appends a new media item to the end of the queue.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
item The item to append. Must not benull.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueInsertAndPlayItem(GoogleApiClient apiClient,MediaQueueItem item, int insertBeforeItemId, long playPosition,JSONObject customData)

A convenience method that inserts a single item into the queue and starts playing it at the specified position.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
item The item to insert. Must not benull.
insertBeforeItemId ID of the item that will be located immediately after the inserted item. If the value is MediaQueueItem.INVALID_ITEM_ID,or no item with this ID can be found, the inserted item will be appended to the end of the queue.
playPosition The initial playback position for the item when it is first played, in milliseconds from the beginning of the stream. This value is ignored when the same item is played again, e.g. when the queue repeats, or this item is later jumped to. In those cases the item'sstartTimeis used.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException IfplayPositionis negative.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueInsertAndPlayItem(GoogleApiClient apiClient,MediaQueueItem item, int insertBeforeItemId,JSONObject customData)

A convenience method that inserts a single item into the queue and starts playing it.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
item The item to insert. Must not benull.
insertBeforeItemId ID of the item that will be located immediately after the inserted item. If the value is MediaQueueItem.INVALID_ITEM_ID,or no item with this ID can be found, the inserted item will be appended to the end of the queue.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueInsertItems(GoogleApiClient apiClient,MediaQueueItem[] itemsToInsert, int insertBeforeItemId,JSONObject customData)

Inserts a list of new media items into the queue.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemsToInsert List of items to insert into the queue, in the order that they should be played. The itemId field of the items should be unassigned or the request will fail with an INVALID_PARAMS error. Must not benullor empty.
insertBeforeItemId ID of the item that will be located immediately after the inserted list. If the value is MediaQueueItem.INVALID_ITEM_IDor invalid, the inserted list will be appended to the end of the queue.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException IfitemsToInsertisnullor empty.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueJumpToItem(GoogleApiClient apiClient, int itemId,JSONObject customData)

Plays the item withitemIdin the queue.

IfitemIdis not found in the queue, this method will report success without sending a request to the receiver.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemId The ID of the item to which to jump.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueJumpToItem(GoogleApiClient apiClient, int itemId, long playPosition,JSONObject customData)

Plays the item withitemIdin the queue. The media item starts playback atplayPosition.

IfitemIdis not found in the queue, this method will report success without sending a request to the receiver.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemId The ID of the item to which to jump.
playPosition The initial playback position for the item when it is first played, in milliseconds from the beginning of the stream. This value is ignored when the same item is played again, e.g. when the queue repeats, or this item is later jumped to. In those cases the item'sstartTimeis used.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException IfplayPositionis negative.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueLoad(GoogleApiClient apiClient,MediaQueueItem[] items, int startIndex, int repeatMode, long playPosition,JSONObject customData)

Loads and optionally starts playback of a new queue of media items. The media item atstartIndexstarts playback atplayPosition.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
items Array of items to load, in the order that they should be played. Must not be nullor empty.
startIndex The array index of the item in theitemsarray that should be played first (i.e., it will become the currentItem). IfrepeatModeis MediaStatus.REPEAT_MODE_REPEAT_OFFplayback will end when the last item in the array is played.

This may be useful for continuation scenarios where the user was already using the sender application and in the middle decides to cast. This lets the sender application avoid mapping between the local and remote queue positions and/or avoid issuing an extra request to update the queue.

This value must be less than the length ofitems.

repeatMode The repeat playback mode for the queue. One of MediaStatus.REPEAT_MODE_REPEAT_OFF, MediaStatus.REPEAT_MODE_REPEAT_ALL, MediaStatus.REPEAT_MODE_REPEAT_SINGLEor MediaStatus.REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE.
playPosition The initial playback position for the item atstartIndexwhen it is first played, in milliseconds from the beginning of the stream. This value is ignored if the same item is played again, e.g. when the queue repeats, or this item is later jumped to. In those cases the item'sstartTimeis used.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException Ifitemsisnullor empty,startIndexis out of range, orplayPositionis negative.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueLoad(GoogleApiClient apiClient,MediaQueueItem[] items, int startIndex, int repeatMode,JSONObject customData)

Loads and optionally starts playback of a new queue of media items.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
items Array of items to load, in the order that they should be played. Must not be nullor empty.
startIndex The array index of the item in theitemsarray that should be played first (i.e., it will become the currentItem). IfrepeatModeis MediaStatus.REPEAT_MODE_REPEAT_OFFplayback will end when the last item in the array is played.

This may be useful for continuation scenarios where the user was already using the sender application and in the middle decides to cast. This lets the sender application avoid mapping between the local and remote queue positions and/or avoid issuing an extra request to update the queue.

This value must be less than the length ofitems.

repeatMode The repeat playback mode for the queue. One of MediaStatus.REPEAT_MODE_REPEAT_OFF, MediaStatus.REPEAT_MODE_REPEAT_ALL, MediaStatus.REPEAT_MODE_REPEAT_SINGLEor MediaStatus.REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException Ifitemsisnullor empty, orstartIndex is out of range.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueMoveItemToNewIndex(GoogleApiClient apiClient, int itemId, int newIndex,JSONObject customData)

Moves the item withitemIdto a new position in the queue.

IfitemIdis not found in the queue, either because it wasn't there originally or it was removed by another sender before calling this function, this function will silently return without sending a request to the receiver.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemId The ID of the item to be moved.
newIndex The new index of the item. If the value is negative, an error will be returned. If the value is out of bounds, or becomes out of bounds because the queue was shortened by another sender while this request is in progress, the item will be moved to the end of the queue.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueNext(GoogleApiClient apiClient,JSONObject customData)

Jumps to the next item in the queue.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queuePrev(GoogleApiClient apiClient,JSONObject customData)

Jumps to the previous item in the queue.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueRemoveItem(GoogleApiClient apiClient, int itemId,JSONObject customData)

Removes the item withitemIdfrom the queue.

IfitemIdis not found in the queue, this method will silently return without sending a request to the receiver. AitemIdmay not be in the queue because it wasn't originally in the queue, or it was removed by another sender.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemId The ID of the item to be removed.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueRemoveItems(GoogleApiClient apiClient, int[] itemIdsToRemove,JSONObject customData)

Removes a list of items from the queue. If the remaining queue is empty, the media session will be terminated.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemIdsToRemove The list of media item IDs to remove. Must not benullor empty.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueReorderItems(GoogleApiClient apiClient, int[] itemIdsToReorder, int insertBeforeItemId,JSONObject customData)

Reorder a list of media items in the queue.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemIdsToReorder The list of media item IDs to reorder, in the new order. Any other items currently in the queue will maintain their existing order. The list will be inserted just before the item specified byinsertBeforeItemId,or at the end of the queue ifinsertBeforeItemIdis MediaQueueItem.INVALID_ITEM_ID.

For example:

If insertBeforeItemId is not specified
Existing queue: "A", "D", "G", "H", "B", "E"
itemIds: "D", "H", "B"
New Order: "A", "G", "E", "D", "H", "B"

If insertBeforeItemId is "A"
Existing queue: "A", "D", "G", "H", "B"
itemIds: "D", "H", "B"
New Order: "D", "H", "B", "A", "G", "E"

If insertBeforeItemId is "G"
Existing queue: "A", "D", "G", "H", "B"
itemIds: "D", "H", "B"
New Order: "A", "D", "H", "B", "G", "E"

If any of the items does not exist it will be ignored. Must not be nullor empty.

insertBeforeItemId ID of the item that will be located immediately after the reordered list. If set to MediaQueueItem.INVALID_ITEM_ID,the reordered list will be appended at the end of the queue.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueSetRepeatMode(GoogleApiClient apiClient, int repeatMode,JSONObject customData)

Sets the repeat mode of the queue.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
repeatMode The repeat playback mode for the queue. One of MediaStatus.REPEAT_MODE_REPEAT_OFF, MediaStatus.REPEAT_MODE_REPEAT_ALL, MediaStatus.REPEAT_MODE_REPEAT_SINGLEor MediaStatus.REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> queueUpdateItems(GoogleApiClient apiClient,MediaQueueItem[] itemsToUpdate,JSONObject customData)

Updates properties of a subset of the existing items in the media queue.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
itemsToUpdate List of queue items to be updated. The items will retain the existing order and will be fully replaced with the ones provided, including the media information. Any other items currently in the queue will remain unchanged. The tracks information can not change once the item is loaded (if the item is the currentItem). If any of the items does not exist it will be ignored.
customData Custom application-specific data to pass along with the request. May be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> requestStatus(GoogleApiClient apiClient)

Requests updated media status information from the receiver. RemoteMediaPlayer.OnStatusUpdatedListenercallback will be triggered if the received media status is different than the current media status. This will also update the internal state of theRemoteMediaPlayer object with the current state of the receiver, including the current session ID. This method should be called when joining an application that supports the media control namespace.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> seek(GoogleApiClient apiClient, long position)

Seeks to a new position within the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
position The new position, in milliseconds from the beginning of the stream.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> seek(GoogleApiClient apiClient, long position, int resumeState,JSONObject customData)

Seeks to a new position within the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
position The new position, in milliseconds from the beginning of the stream.
resumeState The action to take after the seek operation has finished.
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> seek(GoogleApiClient apiClient, long position, int resumeState)

Seeks to a new position within the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
position The new position, in milliseconds from the beginning of the stream.
resumeState The action to take after the seek operation has finished.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> setActiveMediaTracks(GoogleApiClient apiClient, long[] trackIds)

Sets the active media tracks.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
trackIds The media track IDs. If an empty array, the current set of active trackIdswill be removed.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException IftrackIdsisnull.

public voidsetOnMetadataUpdatedListener(RemoteMediaPlayer.OnMetadataUpdatedListener listener)

Sets the RemoteMediaPlayer.OnMetadataUpdatedListenerto get metadata updates.

public voidsetOnPreloadStatusUpdatedListener(RemoteMediaPlayer.OnPreloadStatusUpdatedListener listener)

public voidsetOnQueueStatusUpdatedListener(RemoteMediaPlayer.OnQueueStatusUpdatedListener listener)

Sets the RemoteMediaPlayer.OnQueueStatusUpdatedListenerto get status updates.

public voidsetOnStatusUpdatedListener(RemoteMediaPlayer.OnStatusUpdatedListener listener)

Sets the RemoteMediaPlayer.OnStatusUpdatedListenerto get status updates.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> setStreamMute(GoogleApiClient apiClient, boolean muteState,JSONObject customData)

Toggles the stream muting.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
muteState Whether the stream should be muted or unmuted.
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> setStreamMute(GoogleApiClient apiClient, boolean muteState)

Toggles the stream muting.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
muteState Whether the stream should be muted or unmuted.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> setStreamVolume(GoogleApiClient apiClient, double volume,JSONObject customData)

Sets the stream volume. Ifvolumeis outside of the range [0.0, 1.0], then the value will be clipped.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
volume The new volume, in the range [0.0 - 1.0].
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException If thevolumeis infinity or NaN.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> setStreamVolume(GoogleApiClient apiClient, double volume)

Sets the stream volume of the current media item. When the stream volume has been updated, RemoteMediaPlayer.OnStatusUpdatedListener.onStatusUpdated()will be called.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
volume The new volume, in the range [0.0 - 1.0].
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException If thevolumeis infinity or NaN.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> setTextTrackStyle(GoogleApiClient apiClient,TextTrackStyle trackStyle)

Sets the text track style.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
trackStyle The track style. Must not benull.
Returns
  • APendingResult which can be used to track the progress of the request.
Throws
IllegalArgumentException If thetrackStyleisnull.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> stop(GoogleApiClient apiClient,JSONObject customData)

Stops playback of the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
customData Custom application-specific data to pass along with the request, may be null.
Returns
  • APendingResult which can be used to track the progress of the request.

publicPendingResult<RemoteMediaPlayer.MediaChannelResult> stop(GoogleApiClient apiClient)

Stops playback of the current media item.

Parameters
apiClient The API client with which to perform the operation. Must not be null.
Returns
  • APendingResult which can be used to track the progress of the request.