Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

MediaSessionStatus

class MediaSessionStatus
kotlin.Any
   ↳ androidx.mediarouter.media.MediaSessionStatus

Describes the playback status of a media session.

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

When a media session is created, it is initially in the active state. When the media session ends normally, it transitions to the ended state. If the media session is invalidated due to another session forcibly taking control of the route, then it transitions to the invalidated state. Refer to the documentation of each state for an explanation of its meaning.

To monitor session status, the application should supply a PendingIntent to use as the session status update receiver for a given session start request.

This object is immutable once created using a Builder instance.

Summary

Nested classes

Builder for media session status objects.

Constants
static Int

Session state: Active.

static Int

Session state: Ended.

static Int

Session state: Invalidated.

Public methods
String

Bundle!

Gets a bundle of extras for this status object.

Bundle!

Converts this object to a bundle for serialization.

Long

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

Int

Gets the session state.

Boolean

Returns true if the session's queue is paused.

static MediaSessionStatus!
fromBundle(bundle: Bundle!)

Creates an instance from a bundle.

Constants

SESSION_STATE_ACTIVE

static val SESSION_STATE_ACTIVE: Int

Session state: Active.

Indicates that the media session is active and in control of the route.

Value: 0

SESSION_STATE_ENDED

static val SESSION_STATE_ENDED: Int

Session state: Ended.

Indicates that the media session was ended normally using the end session action.

A terminated media session cannot be used anymore. To play more media, the application must start a new session.

Value: 1

SESSION_STATE_INVALIDATED

static val SESSION_STATE_INVALIDATED: Int

Session state: Invalidated.

Indicates that the media session was invalidated involuntarily due to another session taking control of the route.

An invalidated media session cannot be used anymore. To play more media, the application must start a new session.

Value: 2

Public methods

toString

fun toString(): String

getExtras

fun getExtras(): Bundle!

Gets a bundle of extras for this status object. The extras will be ignored by the media router but they may be used by applications.

asBundle

fun asBundle(): Bundle!

Converts this object to a bundle for serialization.

Return
Bundle!: The contents of the object represented as a bundle.

getTimestamp

fun getTimestamp(): Long

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

Return
Long: The status timestamp in the SystemClock#elapsedRealtime() time base.

getSessionState

fun getSessionState(): Int

Gets the session state.

Return
Int: The session state. One of SESSION_STATE_ACTIVE, SESSION_STATE_ENDED, or SESSION_STATE_INVALIDATED.

isQueuePaused

fun isQueuePaused(): Boolean

Returns true if the session's queue is paused.

Return
Boolean: True if the session's queue is paused.

fromBundle

static fun fromBundle(bundle: Bundle!): MediaSessionStatus!

Creates an instance from a bundle.

Parameters
bundle Bundle!: The bundle, or null if none.
Return
MediaSessionStatus!: The new instance, or null if the bundle was null.