public final class MediaItemStatus
extends Object


Describes the playback status of a media item.

This class is part of the remote playback protocol described by the MediaControlIntent class.

As a media item is played, it transitions through a sequence of states including: pending, buffering, playing, paused, finished, canceled, invalidated, and error. Refer to the documentation of each state for an explanation of its meaning.

While the item is playing, the playback status may also include progress information about the content position and content duration although not all route destinations will report it.

To monitor playback status, the application should supply a PendingIntent to use as the item status update receiver for a given playback request. Note that the status update receiver will only be invoked for major status changes such as a transition from playing to finished.

The status update receiver will not be invoked for minor progress updates such as changes to playback position or duration. If the application wants to monitor playback progress, then it must use the get status request to poll for changes periodically and estimate the playback position while playing. Note that there may be a significant power impact to polling so the application is advised only to poll when the screen is on and never more than about once every 5 seconds or so.

This object is immutable once created using a MediaItemStatus.Builder instance.


Nested classes

class MediaItemStatus.Builder

Builder for media item status objects



Bundle extra: HTTP response headers.


Integer extra: HTTP status code.


Playback state: Buffering or seeking to a new position.


Playback state: Canceled.


Playback state: Playback halted or aborted due to an error.


Playback state: Finished.


Playback state: Invalidated.


Playback state: Paused.


Playback state: Pending.


Playback state: Playing.

Public methods

Bundle asBundle()

Converts this object to a bundle for serialization.

static MediaItemStatus fromBundle(Bundle bundle)

Creates an instance from a bundle.

long getContentDuration()

Gets the total duration of the content to be played as a long integer number of milliseconds.

long getContentPosition()

Gets the content playback position as a long integer number of milliseconds from the beginning of the content.

Bundle getExtras()

Gets a bundle of extras for this status object.

int getPlaybackState()

Gets the playback state of the media item.

long getTimestamp()

Gets the timestamp associated with the status information in milliseconds since boot in the SystemClock.elapsedRealtime() time base.

String toString()

Inherited methods



public static final String EXTRA_HTTP_RESPONSE_HEADERS

Bundle extra: HTTP response headers.

Specifies the HTTP response headers that were returned when the content was requested from the network. The headers may include additional information about the content or any errors conditions that were encountered while trying to fetch the content.

The value is a Bundle of string based key-value pairs that describe the HTTP response headers.

Constant Value: ""


public static final String EXTRA_HTTP_STATUS_CODE

Integer extra: HTTP status code.

Specifies the HTTP status code that was encountered when the content was requested after all redirects were followed. This key only needs to specified when the content uri uses the HTTP or HTTPS scheme and an error occurred. This key may be omitted if the content was able to be played successfully; there is no need to report a 200 (OK) status code.

The value is an integer HTTP status code, such as 401 (Unauthorized), 404 (Not Found), or 500 (Server Error), or 0 if none.

Constant Value: ""


public static final int PLAYBACK_STATE_BUFFERING

Playback state: Buffering or seeking to a new position.