public class

MediaStatus

extends Object
implements Parcelable
java.lang.Object
   ↳ com.google.android.gms.cast.MediaStatus

Class Overview

A class that holds status information about some media or media queue. The current MediaStatus can be obtained from the RemoteMediaPlayer.

Each media session is associated with a media queue on the receiver application. The list of media items in the current queue can be obtained from getQueueItems(). Media items are assigned a unique item ID. Accessors for individual item and values of properties of the queue are also provided here.

getCurrentItemId(), getLoadingItemId() and getPreloadedItemId() tells which item is playing, which item is loading and which item has been preloaded on the receiver.

Summary

Constants
long COMMAND_PAUSE A flag (bitmask) indicating that a media item can be paused.
long COMMAND_SEEK A flag (bitmask) indicating that a media item supports seeking.
long COMMAND_SET_VOLUME A flag (bitmask) indicating that a media item's audio volume can be changed.
long COMMAND_SKIP_BACKWARD A flag (bitmask) indicating that a media item supports skipping backward.
long COMMAND_SKIP_FORWARD A flag (bitmask) indicating that a media item supports skipping forward.
long COMMAND_TOGGLE_MUTE A flag (bitmask) indicating that a media item's audio can be muted.
int IDLE_REASON_CANCELED Constant indicating that the player is idle because playback has been canceled in response to a STOP command.
int IDLE_REASON_ERROR Constant indicating that the player is idle because a playback error has occurred.
int IDLE_REASON_FINISHED Constant indicating that the player is idle because playback has finished.
int IDLE_REASON_INTERRUPTED Constant indicating that the player is idle because playback has been interrupted by a LOAD command.
int IDLE_REASON_NONE Constant indicating that the player currently has no idle reason.
int PLAYER_STATE_BUFFERING Constant indicating that the media player is buffering.
int PLAYER_STATE_IDLE Constant indicating that the media player is idle.
int PLAYER_STATE_PAUSED Constant indicating that the media player is paused.
int PLAYER_STATE_PLAYING Constant indicating that the media player is playing.
int PLAYER_STATE_UNKNOWN Constant indicating unknown player state.
int REPEAT_MODE_REPEAT_ALL Constant indicating that the items in the queue will be played indefinitely.
int REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE Constant indicating that the items in the queue will be played indefinitely, and the order of the items will be randomly shuffled once the last item in the queue finishes.
int REPEAT_MODE_REPEAT_OFF Constant indicating that when the queue is completed the media session is terminated.
int REPEAT_MODE_REPEAT_SINGLE Constant indicating that the current item will be repeated indefinitely.
[Expand]
Inherited Constants
From interface android.os.Parcelable
Public Methods
boolean equals(Object other)
long[] getActiveTrackIds()
Returns the list of active track IDs set by the cast receiver, if any, otherwise null.
AdBreakStatus getAdBreakStatus()
Returns the received AdBreakStatus.
AdBreakInfo getCurrentAdBreak()
Returns the AdBreakInfo of the currently playing ad break on the cast receiver.
AdBreakClipInfo getCurrentAdBreakClip()
Returns the AdBreakClipInfo of the currently playing ad break clip on the cast receiver.
int getCurrentItemId()
Returns the item ID of the item that that was active in the queue (it may not be playing) at the time the media status change happened.
JSONObject getCustomData()
Returns any custom data that is associated with the media item.
int getIdleReason()
Gets the player state idle reason.
Integer getIndexById(int itemId)
Returns the index of the MediaQueueItem with the given itemId in the playback queue, or null if there is no such item in the queue.
MediaQueueItem getItemById(int itemId)
Returns the MediaQueueItem of the give item ID.
MediaQueueItem getItemByIndex(int index)
Returns the MediaQueueItem at index, or null if index is out of bounds.
int getLoadingItemId()
Returns the item ID of the item that is currently loading (but isn't active in the queue) on the receiver.
MediaInfo getMediaInfo()
Returns the MediaInfo for this item.
double getPlaybackRate()
Gets the current stream playback rate.
int getPlayerState()
Gets the current media player state.
int getPreloadedItemId()
If the next item has been preloaded this returns the preloaded item ID.
MediaQueueItem getQueueItem(int index)
Returns the MediaQueueItem at index, or null if index out of bounds.
MediaQueueItem getQueueItemById(int itemId)
Returns the MediaQueueItem of the give item ID.
int getQueueItemCount()
Returns the number of items in the media queue.
List<MediaQueueItem> getQueueItems()
Returns the list of MediaQueueItem as an unmodifiable list.
int getQueueRepeatMode()
Returns the repeat mode of the media queue.
long getStreamPosition()
Returns the current stream position, in milliseconds.
double getStreamVolume()
Returns the stream's volume.
VideoInfo getVideoInfo()
Returns the last received VideoInfo.
int hashCode()
boolean isMediaCommandSupported(long mediaCommand)
Tests if the stream supports a given control command.
boolean isMute()
Returns the stream's mute state.
boolean isPlayingAd()
Returns true is the receiver is playing an ad.
void writeToParcel(Parcel out, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final long COMMAND_PAUSE

A flag (bitmask) indicating that a media item can be paused.

Constant Value: 1 (0x0000000000000001)

public static final long COMMAND_SEEK

A flag (bitmask) indicating that a media item supports seeking.

Constant Value: 2 (0x0000000000000002)

public static final long COMMAND_SET_VOLUME

A flag (bitmask) indicating that a media item's audio volume can be changed.

Constant Value: 4 (0x0000000000000004)

public static final long COMMAND_SKIP_BACKWARD

A flag (bitmask) indicating that a media item supports skipping backward.

Constant Value: 32 (0x0000000000000020)

public static final long COMMAND_SKIP_FORWARD

A flag (bitmask) indicating that a media item supports skipping forward.

Constant Value: 16 (0x0000000000000010)

public static final long COMMAND_TOGGLE_MUTE

A flag (bitmask) indicating that a media item's audio can be muted.

Constant Value: 8 (0x0000000000000008)

public static final int IDLE_REASON_CANCELED

Constant indicating that the player is idle because playback has been canceled in response to a STOP command.

Constant Value: 2 (0x00000002)

public static final int IDLE_REASON_ERROR

Constant indicating that the player is idle because a playback error has occurred.

Constant Value: 4 (0x00000004)

public static final int IDLE_REASON_FINISHED

Constant indicating that the player is idle because playback has finished.

Constant Value: 1 (0x00000001)

public static final int IDLE_REASON_INTERRUPTED

Constant indicating that the player is idle because playback has been interrupted by a LOAD command.

Constant Value: 3 (0x00000003)

public static final int IDLE_REASON_NONE

Constant indicating that the player currently has no idle reason.

Constant Value: 0 (0x00000000)

public static final int PLAYER_STATE_BUFFERING

Constant indicating that the media player is buffering.

Constant Value: 4 (0x00000004)

public static final int PLAYER_STATE_IDLE

Constant indicating that the media player is idle.

Constant Value: 1 (0x00000001)

public static final int PLAYER_STATE_PAUSED

Constant indicating that the media player is paused.

Constant Value: 3 (0x00000003)

public static final int PLAYER_STATE_PLAYING

Constant indicating that the media player is playing.

Constant Value: 2 (0x00000002)

public static final int PLAYER_STATE_UNKNOWN

Constant indicating unknown player state.

Constant Value: 0 (0x00000000)

public static final int REPEAT_MODE_REPEAT_ALL

Constant indicating that the items in the queue will be played indefinitely.

Constant Value: 1 (0x00000001)

public static final int REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE

Constant indicating that the items in the queue will be played indefinitely, and the order of the items will be randomly shuffled once the last item in the queue finishes. The queue will continue to play starting from the first item of the shuffled items.

Constant Value: 3 (0x00000003)

public static final int REPEAT_MODE_REPEAT_OFF

Constant indicating that when the queue is completed the media session is terminated.

Constant Value: 0 (0x00000000)

public static final int REPEAT_MODE_REPEAT_SINGLE

Constant indicating that the current item will be repeated indefinitely.

Constant Value: 2 (0x00000002)

Public Methods

public boolean equals (Object other)

Parameters
other Object
Returns
boolean

public long[] getActiveTrackIds ()

Returns the list of active track IDs set by the cast receiver, if any, otherwise null.

Returns
long[]

public AdBreakStatus getAdBreakStatus ()

Returns the received AdBreakStatus.

Returns
AdBreakStatus

public AdBreakInfo getCurrentAdBreak ()

Returns the AdBreakInfo of the currently playing ad break on the cast receiver. If the cast receiver is not playing an ad break, null will be returned.

Returns
AdBreakInfo

public AdBreakClipInfo getCurrentAdBreakClip ()

Returns the AdBreakClipInfo of the currently playing ad break clip on the cast receiver. If the cast receiver is not playing an ad break clip, null will be returned.

Returns
AdBreakClipInfo

public int getCurrentItemId ()

Returns the item ID of the item that that was active in the queue (it may not be playing) at the time the media status change happened.

Returns
int

public JSONObject getCustomData ()

Returns any custom data that is associated with the media item.

Returns
JSONObject

public int getIdleReason ()

Gets the player state idle reason. This value is only meaningful if the player state is in fact PLAYER_STATE_IDLE.

Returns
int

public Integer getIndexById (int itemId)

Returns the index of the MediaQueueItem with the given itemId in the playback queue, or null if there is no such item in the queue.

Parameters
itemId int
Returns
Integer

public MediaQueueItem getItemById (int itemId)

Returns the MediaQueueItem of the give item ID. Returns null if not found.

Parameters
itemId int
Returns
MediaQueueItem

public MediaQueueItem getItemByIndex (int index)

Returns the MediaQueueItem at index, or null if index is out of bounds.

Parameters
index int
Returns
MediaQueueItem

public int getLoadingItemId ()

Returns the item ID of the item that is currently loading (but isn't active in the queue) on the receiver. Returns INVALID_ITEM_ID if no item is currently loading.

Returns
int

public MediaInfo getMediaInfo ()

Returns the MediaInfo for this item.

Returns
MediaInfo

public double getPlaybackRate ()

Gets the current stream playback rate. This will be negative if the stream is seeking backwards, 0 if the stream is paused, 1 if the stream is playing normally, and some other postive value if the stream is seeking forwards.

Returns
double

public int getPlayerState ()

Gets the current media player state.

Returns
int

public int getPreloadedItemId ()

If the next item has been preloaded this returns the preloaded item ID. Otherwise returns INVALID_ITEM_ID.

Returns
int

public MediaQueueItem getQueueItem (int index)

Returns the MediaQueueItem at index, or null if index out of bounds.

Parameters
index int
Returns
MediaQueueItem

public MediaQueueItem getQueueItemById (int itemId)

Returns the MediaQueueItem of the give item ID. Returns null if not found.

Parameters
itemId int
Returns
MediaQueueItem

public int getQueueItemCount ()

Returns the number of items in the media queue.

Returns
int

public List<MediaQueueItem> getQueueItems ()

Returns the list of MediaQueueItem as an unmodifiable list.

Returns
List<MediaQueueItem>

public int getQueueRepeatMode ()

Returns the repeat mode of the media queue.

Returns
int

public long getStreamPosition ()

Returns the current stream position, in milliseconds.

Returns
long

public double getStreamVolume ()

Returns the stream's volume.

Returns
double

public VideoInfo getVideoInfo ()

Returns the last received VideoInfo. If the video information of the current media was not received from the cast receiver, null will be returned.

Returns
VideoInfo

public int hashCode ()

Returns
int

public boolean isMediaCommandSupported (long mediaCommand)

Tests if the stream supports a given control command.

Parameters
mediaCommand long: The media command.
Returns
boolean true if the command is supported, false otherwise.

public boolean isMute ()

Returns the stream's mute state.

Returns
boolean

public boolean isPlayingAd ()

Returns true is the receiver is playing an ad.

Returns
boolean

public void writeToParcel (Parcel out, int flags)

Parameters
out Parcel
flags int