implements Cast.MessageReceivedCallback
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 a PendingResult
      for this purpose. In case of error, such as having lost the connection to the service, the
      PendingResult
      will provide a status of CastStatusCodes.FAILED.
Any media session created by calling 
      load(MediaInfo) or 
      queueLoad(MediaQueueItem[], int, int, long, JSONObject) will be associated with a
      queue on the receiver application. If the media session is created by calling 
      load(MediaInfo), then the media queue is a non-repeatable queue with a single
      item, and other queuing related operations such as 
      queueInsertItems(MediaQueueItem[], int, JSONObject) and 
      queueUpdateItems(MediaQueueItem[], JSONObject) can still be applied on top of
      it.
Nested Class Summary
| class | RemoteMediaClient.Callback | The callback for tracking player status changes. | |
| interface | RemoteMediaClient.Listener | This interface is deprecated. Use 
              RemoteMediaClient.Callbackinstead. | |
| interface | RemoteMediaClient.MediaChannelResult | The result of a media command. | |
| interface | RemoteMediaClient.ParseAdsInfoCallback | The callback interface for parsing ads
              information from the custom data inside the MediaStatus. | |
| interface | RemoteMediaClient.ProgressListener | The listener interface for getting updates on the progress of the currently playing media. | |
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_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. | 
Field Summary
| public static final String | NAMESPACE | Returns the namespace used by the 
              RemoteMediaClientto send media commands. | 
Public Method Summary
| void | 
                  
                  addListener(RemoteMediaClient.Listener
                  listener)
                   
                    This method is deprecated. Use  
                    registerCallback(Callback)instead. | 
| boolean | 
                  
                  addProgressListener(RemoteMediaClient.ProgressListener
                  listener, long periodMs)
                   
                    Adds the  
                    RemoteMediaClient.ProgressListenerto the progress updates. | 
| long | 
                  
                  getApproximateAdBreakClipPositionMs()
                   
                    Returns the approximate ad break clip position as calculated from the last
                    received stream information and the elapsed wall-time since that update.
                   | 
| long | 
                  
                  getApproximateLiveSeekableRangeEnd()
                   
                    Returns the approximate end position (in milliseconds) of the live seekable
                    range as calculated from the last received stream information and the elapsed
                    wall-time since that update.
                   | 
| long | 
                  
                  getApproximateLiveSeekableRangeStart()
                   
                    Returns the approximate start position (in milliseconds) of the live seekable
                    range as calculated from the last received stream information and the elapsed
                    wall-time since that update.
                   | 
| long | 
                  
                  getApproximateStreamPosition()
                   
                    Returns the approximate stream position as calculated from the last received
                    stream information and the elapsed wall-time since that update.
                   | 
| MediaQueueItem | 
                  
                  getCurrentItem()
                   
                    Returns the current item in the queue, or  nullif the queue is
                    empty. | 
| int | 
                  
                  getIdleReason()
                   
                    Returns the current idle reason.
                   | 
| MediaQueueItem | 
                  
                  getLoadingItem()
                   
                    Returns the currently loading item in the queue, or  nullif no
                    item is being loaded. | 
| MediaInfo | 
                  
                  getMediaInfo()
                   
                    Returns the current media information, or  nullif there isn't a
                    media session. | 
| MediaQueue | 
                  
                  getMediaQueue()
                   
                    Returns the associated  
                    MediaQueue. | 
| MediaStatus | 
                  
                  getMediaStatus()
                   
                    Returns the current media status, or  nullif there isn't a media
                    session. | 
| String | 
                  
                  getNamespace()
                   
                    Returns the media control namespace.
                   | 
| int | 
                  
                  getPlayerState()
                   
                    Returns the current player state.
                   | 
| MediaQueueItem | 
                  
                  getPreloadedItem()
                   
                    Returns the currently preloaded item in the queue, or  nullif no
                    item has been preloaded. | 
| long | 
                  
                  getStreamDuration()
                   
                    Convenience method for getting the stream duration.
                   | 
| boolean | 
                  
                  hasMediaSession()
                   
                    Returns  trueif there is a media session, that is, media being
                    loaded on the remote receiver. | 
| boolean | 
                  
                  isBuffering()
                   
                    Returns  trueif the current media is buffering. | 
| boolean | 
                  
                  isLiveStream()
                   
                    Returns  trueif the currently loaded media is a live stream,
                    otherwise returnsfalse. | 
| boolean | 
                  
                  isLoadingNextItem()
                   
                    Returns  trueif the next item is being loaded. | 
| boolean | 
                  
                  isPaused()
                   
                    Returns  trueif the current media is paused. | 
| boolean | 
                  
                  isPlaying()
                   
                    Returns  trueif the current media is playing. | 
| boolean | 
                  
                  isPlayingAd()
                   
                    Returns  trueif an ad is playing. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  load(MediaInfo mediaInfo, boolean autoplay, long playPosition)
                   
                    This method is deprecated. Use  
                    load(MediaLoadRequestData)instead. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  load(MediaInfo mediaInfo, boolean autoplay, long playPosition, long[]
                  activeTrackIds, JSONObject
                  customData)
                   
                    This method is deprecated. Use  
                    load(MediaLoadRequestData)instead. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  load(MediaInfo mediaInfo)
                   
                    This method is deprecated. Use  
                    load(MediaLoadRequestData)instead. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  load(MediaInfo mediaInfo, MediaLoadOptions mediaLoadOptions)
                   
                    Loads a new media item with specified options.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  load(MediaInfo mediaInfo, boolean autoplay, long playPosition,
                  JSONObject
                  customData)
                   
                    This method is deprecated. Use  
                    load(MediaLoadRequestData)instead. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  load(MediaLoadRequestData loadRequestData)
                   
                    Loads a new media item and/or a queue with specified options.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  load(MediaInfo mediaInfo, boolean autoplay)
                   
                    This method is deprecated. Use  
                    load(MediaLoadRequestData)instead. | 
| void | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  pause()
                   
                    Pauses playback of the current media item.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  play()
                   
                    Begins (or resumes) playback of the current media item.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueAppendItem(MediaQueueItem item, JSONObject
                  customData)
                   
                    Appends a new media item to the end of the queue.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueInsertAndPlayItem(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<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueInsertAndPlayItem(MediaQueueItem item, int insertBeforeItemId,
                  JSONObject
                  customData)
                   
                    A convenience method that inserts a single item into the queue and starts
                    playing it.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueInsertItems(MediaQueueItem[] itemsToInsert, int
                  insertBeforeItemId, JSONObject
                  customData)
                   
                    Inserts a list of new media items into the queue.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueJumpToItem(int itemId, long playPosition, JSONObject
                  customData)
                   
                    Plays the item with  itemIdin the queue. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueLoad(MediaQueueItem[] items, int startIndex, int repeatMode, long
                  playPosition, JSONObject
                  customData)
                   
                    Loads and optionally starts playback of a new queue of media items.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueLoad(MediaQueueItem[] items, int startIndex, int repeatMode,
                  JSONObject
                  customData)
                   
                    Loads and optionally starts playback of a new queue of media items.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueMoveItemToNewIndex(int itemId, int newIndex, JSONObject
                  customData)
                   
                    Moves the item with  itemIdto a new position in the queue. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueRemoveItems(int[] itemIdsToRemove, JSONObject
                  customData)
                   
                    Removes a list of items from the queue.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueReorderItems(int[] itemIdsToReorder, int insertBeforeItemId,
                  JSONObject
                  customData)
                   
                    Reorders a list of media items in the queue.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  queueUpdateItems(MediaQueueItem[] itemsToUpdate, JSONObject
                  customData)
                   
                    Updates properties of a subset of the existing items in the media queue.
                   | 
| void | 
                  
                  registerCallback(RemoteMediaClient.Callback
                  callback)
                   
                    Registers the  
                    RemoteMediaClient.Callbackto get status updates. | 
| void | 
                  
                  removeListener(RemoteMediaClient.Listener
                  listener)
                   
                    This method is deprecated. Use  
                    unregisterCallback(Callback)instead. | 
| void | 
                  
                  removeProgressListener(RemoteMediaClient.ProgressListener
                  listener)
                   
                    Removes the  
                    RemoteMediaClient.ProgressListener. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  requestStatus()
                   
                    Requests updated media status information from the receiver.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  seek(long position)
                   
                    This method is deprecated. Use  
                    seek(MediaSeekOptions)instead. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  seek(MediaSeekOptions seekOptions)
                   
                    Seeks to a new position as specified in  seekOptions. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  seek(long position, int resumeState, JSONObject
                  customData)
                   
                    This method is deprecated. Use  
                    seek(MediaSeekOptions)instead. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  seek(long position, int resumeState)
                   
                    This method is deprecated. Use  
                    seek(MediaSeekOptions)instead. | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  setActiveMediaTracks(long[] trackIds)
                   
                    Sets the active media tracks.
                   | 
| void | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  setPlaybackRate(double playbackRate, JSONObject
                  customData)
                   
                    Sets the playback rate for the current media item and can pass along custom
                    data.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  setPlaybackRate(double playbackRate)
                   
                    Sets the playback rate for the current media item.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  setStreamMute(boolean muted)
                   
                    Toggles the stream muting.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  setStreamVolume(double volume)
                   
                    Sets the stream volume of the current media item.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  setTextTrackStyle(TextTrackStyle trackStyle)
                   
                    Sets the text track style.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  skipAd()
                   
                    Skips the playing ad.
                   | 
| PendingResult<RemoteMediaClient.MediaChannelResult> | |
| PendingResult<RemoteMediaClient.MediaChannelResult> | 
                  
                  stop()
                   
                    Stops playback of the current media item.
                   | 
| void | 
                  
                  togglePlayback()
                   
                    Toggles remote media playback.
                   | 
| void | 
                  
                  unregisterCallback(RemoteMediaClient.Callback
                  callback)
                   
                    Unregisters the  
                    RemoteMediaClient.Callbackto stop receiving status updates. | 
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.
public static final int RESUME_STATE_PLAY
A resume state indicating that the player should be playing, regardless of its current state.
public static final int RESUME_STATE_UNCHANGED
A resume state indicating that the player state should be left unchanged.
public static final int STATUS_FAILED
A status indicating that a request failed. Equivalent to CastStatusCodes.FAILED.
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 to CastStatusCodes.REPLACED.
public static final int STATUS_SUCCEEDED
A status indicating that a request completed successfully. Equivalent to
            CastStatusCodes.SUCCESS.
Fields
public static final String NAMESPACE
Returns the namespace used by the 
            RemoteMediaClient to send media commands.
Public Methods
public void addListener (RemoteMediaClient.Listener listener)
This method is deprecated.
          Use 
          registerCallback(Callback) instead.
Adds the 
            RemoteMediaClient.Listener to get status updates.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean addProgressListener (RemoteMediaClient.ProgressListener listener, long periodMs)
Adds the 
            RemoteMediaClient.ProgressListener to the progress updates. A registered
            listener can not be registered again with a different period. You must remove the
            existing listener first by calling 
            removeProgressListener(ProgressListener).
Parameters
| listener | The 
                RemoteMediaClient.ProgressListener. | 
|---|---|
| periodMs | Amount of time in milliseconds between subsequent updates. | 
Returns
- trueif- listeneris added. Returns- falseif- listenerwas added before.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public long getApproximateAdBreakClipPositionMs ()
Returns the approximate ad break clip position as calculated from the last received stream information and the elapsed wall-time since that update. If an ad break clip is not currently playing, a default value of 0 will be returned.
Returns
- The approximate ad break clip position, in milliseconds.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public long getApproximateLiveSeekableRangeEnd ()
Returns the approximate end position (in milliseconds) of the live seekable range as calculated from the last received stream information and the elapsed wall-time since that update. For live streams, this is also the live head.
Returns 0 if the channel is not connected or if no media is currently loaded. Returns 0 if the stream is not live stream or there is no seekable range.
public long getApproximateLiveSeekableRangeStart ()
Returns the approximate start position (in milliseconds) of the live seekable range as calculated from the last received stream information and the elapsed wall-time since that update.
Returns 0 if the channel is not connected or if no media is currently loaded. Returns 0 if the stream is not live stream or there is no seekable range.
public long getApproximateStreamPosition ()
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.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public MediaQueueItem getCurrentItem ()
Returns the current item in the queue, or null if the queue is
            empty.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public int getIdleReason ()
Returns the current idle reason.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public MediaQueueItem getLoadingItem ()
Returns the currently loading item in the queue, or null if no item is
            being loaded.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public MediaInfo getMediaInfo ()
Returns the current media information, or null if there isn't a media
            session.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public MediaQueue getMediaQueue ()
Returns the associated MediaQueue.
            To access the list containing only the previous, current, and next MediaQueueItem,
            see MediaStatus.getQueueItems().
public MediaStatus getMediaStatus ()
Returns the current media status, or null if there isn't a media
            session.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public String getNamespace ()
Returns the media control namespace.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public int getPlayerState ()
Returns the current player state. One of MediaStatus.PLAYER_STATE_UNKNOWN,
            MediaStatus.PLAYER_STATE_IDLE,
            
            MediaStatus.PLAYER_STATE_BUFFERING, MediaStatus.PLAYER_STATE_PAUSED
            and MediaStatus.PLAYER_STATE_PLAYING.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public MediaQueueItem getPreloadedItem ()
Returns the currently preloaded item in the queue, or null if no item
            has been preloaded.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public long getStreamDuration ()
Convenience method for getting the stream duration.
Returns
- The stream duration, in milliseconds.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean hasMediaSession ()
Returns true if there is a media session, that is, media being loaded
            on the remote receiver. Otherwise returns false.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean isBuffering ()
Returns true if the current media is buffering.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean isLiveStream ()
Returns true if the currently loaded media is a live stream, otherwise
            returns false.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean isLoadingNextItem ()
Returns true if the next item is being loaded.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean isPaused ()
Returns true if the current media is paused.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean isPlaying ()
Returns true if the current media is playing.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public boolean isPlayingAd ()
Returns true if an ad is playing.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> load (MediaInfo mediaInfo, boolean autoplay, long playPosition)
This method is deprecated.
          Use 
          load(MediaLoadRequestData) instead.
Loads and optionally starts playback of a new media item. The media item starts
            playback at playPosition.
Parameters
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> load (MediaInfo mediaInfo, boolean autoplay, long playPosition, long[] activeTrackIds, JSONObject customData)
This method is deprecated.
          Use 
          load(MediaLoadRequestData) instead.
Loads and optionally starts playback of a new media item. The media item starts
            playback at playPosition. This method optionally sends custom data as a
            JSONObject with
            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
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> load (MediaInfo mediaInfo)
This method is deprecated.
          Use 
          load(MediaLoadRequestData) instead.
Loads and automatically starts playback of a new media item.
Parameters
| mediaInfo | An object describing the media item to load. Must not be null | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request
Throws
| IllegalStateException | If this method is not called on the main thread | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> load (MediaInfo mediaInfo, MediaLoadOptions mediaLoadOptions)
Loads a new media item with specified options.
It is recommended to use 
            load(MediaLoadRequestData) instead, which is an advanced load command
            supporting loading a single item or a queue with additional options.
Parameters
| mediaInfo | The media item to load. | 
|---|---|
| mediaLoadOptions | The load options. See MediaLoadOptionsfor what options that can be specified. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> load (MediaInfo mediaInfo, boolean autoplay, long playPosition, JSONObject customData)
This method is deprecated.
          Use 
          load(MediaLoadRequestData) instead.
Loads and optionally starts playback of a new media item. The media item starts
            playback at playPosition. This method optionally sends custom data as a
            JSONObject with
            the load request.
Parameters
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> load (MediaLoadRequestData loadRequestData)
Loads a new media item and/or a queue with specified options.
For details, review MediaLoadRequestData.
Parameters
| loadRequestData | the data specifying how the media should be loaded. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If both mediaInfoandqueueDataare null. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> load (MediaInfo mediaInfo, boolean autoplay)
This method is deprecated.
          Use 
          load(MediaLoadRequestData) instead.
Loads and optionally starts playback of a new media item.
Parameters
| mediaInfo | An object describing the media item to load. Must not be null. | 
|---|---|
| autoplay | Whether playback should start immediately. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> pause ()
Pauses playback of the current media item.
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> pause (JSONObject customData)
Pauses playback of the current media item.
Parameters
| customData | Custom application-specific data to pass along with the request, may be null. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> play ()
Begins (or resumes) playback of the current media item.
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> play (JSONObject customData)
Begins (or resumes) playback of the current media item.
Parameters
| customData | Custom application-specific data to pass along with the request, may be null. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queueAppendItem (MediaQueueItem item, JSONObject customData)
Appends a new media item to the end of the queue.
Parameters
| item | The item to append. Must not be null. | 
|---|---|
| customData | Custom application-specific data to pass along with the request. May be null. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|---|
| IllegalArgumentException | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueInsertAndPlayItem (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
| item | The item to insert. Must not be null. | 
|---|---|
| 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, for example, when the queue repeats, or this item is later
                jumped to. In those cases the item's startTimeis used. | 
| customData | Custom application-specific data to pass along with the request. May be null. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If playPositionis negative. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueInsertAndPlayItem (MediaQueueItem item, int insertBeforeItemId, JSONObject customData)
A convenience method that inserts a single item into the queue and starts playing it.
Parameters
| item | The item to insert. Must not be null. | 
|---|---|
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queueInsertItems (MediaQueueItem[] itemsToInsert, int insertBeforeItemId, JSONObject customData)
Inserts a list of new media items into the queue.
Parameters
| 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 be nullor 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If itemsToInsertisnullor empty. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueJumpToItem (int itemId, JSONObject customData)
Plays the item with itemId in the queue.
If itemId is not found in the queue, this method will report success
            without sending a request to the receiver.
Parameters
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queueJumpToItem (int itemId, long playPosition, JSONObject customData)
Plays the item with itemId in the queue. The media item starts playback
            at playPosition.
If itemId is not found in the queue, this method will report success
            without sending a request to the receiver.
Parameters
| 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, for example, when the queue repeats, or this item is later
                jumped to. In those cases the item's startTimeis used. | 
| customData | Custom application-specific data to pass along with the request. May be null. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If playPositionis negative. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueLoad (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
            at startIndex starts playback at playPosition.
It is recommended to use 
            load(MediaLoadRequestData) instead, which is an advanced load command
            supporting loading a single item or a queue with additional options.
Parameters
| 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 the itemsarray that should be
                played first (that is, 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 of items. | 
| 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 at startIndexwhen it
                is first played, in milliseconds from the beginning of the stream. This value is
                ignored if the same item is played again, for example, 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If itemsisnullor empty,startIndexis
                out of range, orplayPositionis negative. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueLoad (MediaQueueItem[] items, int startIndex, int repeatMode, JSONObject customData)
Loads and optionally starts playback of a new queue of media items.
It is recommended to use 
            load(MediaLoadRequestData) instead, which is an advanced load command
            supporting loading a single item or a queue with additional options.
Parameters
| 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 the itemsarray that should be
                played first (that is, 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 of items. | 
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If itemsisnullor empty, orstartIndexis out of range. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueMoveItemToNewIndex (int itemId, int newIndex, JSONObject customData)
Moves the item with itemId to a new position in the queue.
If itemId is not found in the queue, either because it wasn't there
            originally or it was removed by another sender before calling this method, this method
            will silently return without sending a request to the receiver.
Parameters
| itemId | The ID of the item to be moved. | 
|---|---|
| newIndex | The new index of the item. If the value is negative, an error 
                CastStatusCodes.INVALID_REQUESTwill 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queueNext (JSONObject customData)
Jumps to the next item in the queue.
Parameters
| customData | Custom application-specific data to pass along with the request. May be null. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queuePrev (JSONObject customData)
Jumps to the previous item in the queue.
Parameters
| customData | Custom application-specific data to pass along with the request. May be null. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queueRemoveItem (int itemId, JSONObject customData)
Removes the item with itemId from the queue.
If itemId is not found in the queue, this method will silently return
            without sending a request to the receiver. A itemId may not be in the
            queue because it wasn't originally in the queue, or it was removed by another
            sender.
Parameters
| itemId | The ID of the item to be removed. | 
|---|---|
| customData | Custom application-specific data to pass along with the request. May be null. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queueRemoveItems (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
| itemIdsToRemove | The list of media item IDs to remove. Must not be nullor
                empty. | 
|---|---|
| customData | Custom application-specific data to pass along with the request. May be null. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|---|
| IllegalArgumentException | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueReorderItems (int[] itemIdsToReorder, int insertBeforeItemId, JSONObject customData)
Reorders a list of media items in the queue.
Parameters
| 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 by insertBeforeItemId, or at
                  the end of the queue ifinsertBeforeItemIdis
                  MediaQueueItem.INVALID_ITEM_ID.For example: If insertBeforeItemId is not specified If insertBeforeItemId is "A" If insertBeforeItemId is "G" Items that do not exist will be ignored Must not be  | 
|---|---|
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|---|
| IllegalArgumentException | 
public PendingResult<RemoteMediaClient.MediaChannelResult> queueSetRepeatMode (int repeatMode, JSONObject customData)
Sets the repeat mode of the queue.
Parameters
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> queueUpdateItems (MediaQueueItem[] itemsToUpdate, JSONObject customData)
Updates properties of a subset of the existing items in the media queue.
Parameters
| 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). Items that do not exist will be ignored. | 
|---|---|
| customData | Custom application-specific data to pass along with the request. May be null. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public void registerCallback (RemoteMediaClient.Callback callback)
Registers the 
            RemoteMediaClient.Callback to get status updates.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public void removeListener (RemoteMediaClient.Listener listener)
This method is deprecated.
          Use 
          unregisterCallback(Callback) instead.
Removes the 
            RemoteMediaClient.Listener.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public void removeProgressListener (RemoteMediaClient.ProgressListener listener)
Removes the 
            RemoteMediaClient.ProgressListener.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> requestStatus ()
Requests updated media status information from the receiver. 
            RemoteMediaClient.Listener callback will be triggered, when the updated
            media status has been received. This will also update the internal state of the
            
            RemoteMediaClient 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.
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> seek (long position)
This method is deprecated.
          Use 
          seek(MediaSeekOptions) instead.
Seeks to a new position within the current media item.
Parameters
| position | The new position, in milliseconds from the beginning of the stream. | 
|---|
Returns
- a PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | if this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> seek (MediaSeekOptions seekOptions)
Seeks to a new position as specified in seekOptions.
Parameters
| seekOptions | The options describing the seek request. Check the documentation of MediaSeekOptionsfor details. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> seek (long position, int resumeState, JSONObject customData)
This method is deprecated.
          Use 
          seek(MediaSeekOptions) instead.
Seeks to a new position within the current media item.
Parameters
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> seek (long position, int resumeState)
This method is deprecated.
          Use 
          seek(MediaSeekOptions) instead.
Seeks to a new position within the current media item.
Parameters
| position | The new position, in milliseconds from the beginning of the stream. | 
|---|---|
| resumeState | The action to take after the seek operation has finished. One of 
                RESUME_STATE_UNCHANGED,
                RESUME_STATE_PAUSE, and
                RESUME_STATE_PLAY. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> setActiveMediaTracks (long[] trackIds)
Sets the active media tracks.
Parameters
| trackIds | The media track IDs. If an empty array, the current set of active trackIdswill be removed. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If trackIdsisnull. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public void setParseAdsInfoCallback (RemoteMediaClient.ParseAdsInfoCallback callback)
Sets a 
            RemoteMediaClient.ParseAdsInfoCallback. This callback will be invoked by
            this call before any 
            RemoteMediaClient.Listener instances are invoked. This gives sender app a
            chance to parse information about Ads from the custom data field inside the current
            MediaStatus.
            The returned values of the callback methods will be used by the framework to render Ads
            on various framework provided UIs.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> setPlaybackRate (double playbackRate, JSONObject customData)
Sets the playback rate for the current media item and can pass along custom data.
Parameters
| playbackRate | A value that is between 
                MediaLoadOptions.PLAYBACK_RATE_MINand
                MediaLoadOptions.PLAYBACK_RATE_MAX. The normal rate is 1.0. | 
|---|---|
| customData | custom application-specific data to pass along with the request, may be null. | 
Throws
| IllegalArgumentException | If playbackRate is out of range. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> setPlaybackRate (double playbackRate)
Sets the playback rate for the current media item.
Parameters
| playbackRate | A value that is between 
                MediaLoadOptions.PLAYBACK_RATE_MINand
                MediaLoadOptions.PLAYBACK_RATE_MAXas the multiplier of the normal rate.
                The normal rate is 1.0. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If playbackRate is out of range. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> setStreamMute (boolean muted)
Toggles the stream muting.
Parameters
| muted | trueif the stream should be muted.falseif the
                stream should be unmuted. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> setStreamMute (boolean muted, JSONObject customData)
Toggles the stream muting.
Parameters
| muted | trueif the stream should be muted.falseif the
                stream should be unmuted. | 
|---|---|
| customData | Custom application-specific data to pass along with the request, may be null. | 
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> setStreamVolume (double volume, JSONObject customData)
Sets the stream volume. If volume is outside of the range [0.0, 1.0],
            then the value will be clipped.
Parameters
| 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
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If the volumeis infinity or NaN. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> setStreamVolume (double volume)
Sets the stream volume of the current media item. When the stream volume has been
            updated, 
            RemoteMediaClient.Listener.onStatusUpdated() will be called.
Parameters
| volume | The new volume, in the range [0.0 - 1.0]. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If the volumeis infinity or NaN. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> setTextTrackStyle (TextTrackStyle trackStyle)
Sets the text track style.
Parameters
| trackStyle | The track style. Must not be null. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalArgumentException | If the trackStyleisnull. | 
|---|---|
| IllegalStateException | If this method is not called on the main thread. | 
public PendingResult<RemoteMediaClient.MediaChannelResult> skipAd ()
Skips the playing ad.
Returns
- a PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> stop (JSONObject customData)
Stops playback of the current media item.
Parameters
| customData | Custom application-specific data to pass along with the request, may be null. | 
|---|
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public PendingResult<RemoteMediaClient.MediaChannelResult> stop ()
Stops playback of the current media item.
Returns
- A PendingResultwhich can be used to track the progress of the request.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public void togglePlayback ()
Toggles remote media playback.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|
public void unregisterCallback (RemoteMediaClient.Callback callback)
Unregisters the 
            RemoteMediaClient.Callback to stop receiving status updates.
Throws
| IllegalStateException | If this method is not called on the main thread. | 
|---|