PlaybackState
class PlaybackState : Parcelable
| kotlin.Any | |
| ↳ | android.media.session.PlaybackState |
Playback state for a MediaSession. This includes a state like PlaybackState.STATE_PLAYING, the current playback position, and the current control capabilities.
Summary
| Nested classes | |
|---|---|
|
Builder for |
|
|
|
|
| Constants | |
|---|---|
| static Long |
Indicates this session supports the fast forward command. |
| static Long |
Indicates this session supports the pause command. |
| static Long |
Indicates this session supports the play command. |
| static Long |
Indicates this session supports the play from media id command. |
| static Long |
Indicates this session supports the play from search command. |
| static Long |
Indicates this session supports the play from URI command. |
| static Long |
Indicates this session supports the play/pause toggle command. |
| static Long |
Indicates this session supports the prepare command. |
| static Long |
Indicates this session supports the prepare from media id command. |
| static Long |
Indicates this session supports the prepare from search command. |
| static Long |
Indicates this session supports the prepare from URI command. |
| static Long |
Indicates this session supports the rewind command. |
| static Long |
Indicates this session supports the seek to command. |
| static Long |
Indicates this session supports the set playback speed command. |
| static Long |
Indicates this session supports the set rating command. |
| static Long |
Indicates this session supports the next command. |
| static Long |
Indicates this session supports the previous command. |
| static Long |
Indicates this session supports the skip to queue item command. |
| static Long |
Indicates this session supports the stop command. |
| static Long |
Use this value for the position to indicate the position is not known. |
| static Int |
State indicating this item is currently buffering and will begin playing when enough data has buffered. |
| static Int |
State indicating the class doing playback is currently connecting to a new destination. |
| static Int |
State indicating this item is currently in an error state. |
| static Int |
State indicating this item is currently fast forwarding. |
| static Int |
This is the default playback state and indicates that no media has been added yet, or the performer has been reset and has no content to play. |
| static Int |
State indicating this item is currently paused. |
| static Int |
State indicating this item is currently playing. |
| static Int |
State indicating this item is currently rewinding. |
| static Int |
State indicating the player is currently skipping to the next item. |
| static Int |
State indicating the player is currently skipping to the previous item. |
| static Int |
State indicating the player is currently skipping to a specific item in the queue. |
| static Int |
State indicating this item is currently stopped. |
| Inherited constants | |
|---|---|
| Public methods | |
|---|---|
| Int | |
| Long |
Get the current actions available on this session. |
| Long |
Get the id of the currently active item in the queue. |
| Long |
Get the current buffered position in ms. |
| MutableList<PlaybackState.CustomAction!>! |
Get the list of custom actions. |
| CharSequence! |
Get a user readable error message. |
| Bundle? |
Get any custom extras that were set on this playback state. |
| Long |
Get the elapsed real time at which position was last updated. |
| Float |
Get the current playback speed as a multiple of normal playback. |
| Long |
Get the current playback position in ms. |
| Int |
getState()Get the current state of playback. |
| Boolean |
isActive()Returns whether this is considered as an active playback state. |
| String |
toString() |
| Unit |
writeToParcel(dest: Parcel, flags: Int) |
| Properties | |
|---|---|
| static Parcelable.Creator<PlaybackState!> | |
Constants
ACTION_FAST_FORWARD
static val ACTION_FAST_FORWARD: Long
Indicates this session supports the fast forward command.
Value: 64LACTION_PAUSE
static val ACTION_PAUSE: Long
Indicates this session supports the pause command.
Value: 2LACTION_PLAY
static val ACTION_PLAY: Long
Indicates this session supports the play command.
Value: 4LACTION_PLAY_FROM_MEDIA_ID
static val ACTION_PLAY_FROM_MEDIA_ID: Long
Indicates this session supports the play from media id command.
Value: 1024LACTION_PLAY_FROM_SEARCH
static val ACTION_PLAY_FROM_SEARCH: Long
Indicates this session supports the play from search command.
Value: 2048LACTION_PLAY_FROM_URI
static val ACTION_PLAY_FROM_URI: Long
Indicates this session supports the play from URI command.
Value: 8192LACTION_PLAY_PAUSE
static val ACTION_PLAY_PAUSE: Long
Indicates this session supports the play/pause toggle command.
Value: 512LACTION_PREPARE
static val ACTION_PREPARE: Long
Indicates this session supports the prepare command.
Value: 16384LACTION_PREPARE_FROM_MEDIA_ID
static val ACTION_PREPARE_FROM_MEDIA_ID: Long
Indicates this session supports the prepare from media id command.
Value: 32768LACTION_PREPARE_FROM_SEARCH
static val ACTION_PREPARE_FROM_SEARCH: Long
Indicates this session supports the prepare from search command.
Value: 65536LACTION_PREPARE_FROM_URI
static val ACTION_PREPARE_FROM_URI: Long
Indicates this session supports the prepare from URI command.
Value: 131072LACTION_REWIND
static val ACTION_REWIND: Long
Indicates this session supports the rewind command.
Value: 8LACTION_SEEK_TO
static val ACTION_SEEK_TO: Long
Indicates this session supports the seek to command.
Value: 256LACTION_SET_PLAYBACK_SPEED
static val ACTION_SET_PLAYBACK_SPEED: Long
Indicates this session supports the set playback speed command.
Value: 4194304LACTION_SET_RATING
static val ACTION_SET_RATING: Long
Indicates this session supports the set rating command.
Value: 128LACTION_SKIP_TO_NEXT
static val ACTION_SKIP_TO_NEXT: Long
Indicates this session supports the next command.
Value: 32LACTION_SKIP_TO_PREVIOUS
static val ACTION_SKIP_TO_PREVIOUS: Long
Indicates this session supports the previous command.
Value: 16LACTION_SKIP_TO_QUEUE_ITEM
static val ACTION_SKIP_TO_QUEUE_ITEM: Long
Indicates this session supports the skip to queue item command.
Value: 4096LACTION_STOP
static val ACTION_STOP: Long
Indicates this session supports the stop command.
Value: 1LPLAYBACK_POSITION_UNKNOWN
static val PLAYBACK_POSITION_UNKNOWN: Long
Use this value for the position to indicate the position is not known.
Value: -1LSTATE_BUFFERING
static val STATE_BUFFERING: Int
State indicating this item is currently buffering and will begin playing when enough data has buffered.
Value: 6See Also
STATE_CONNECTING
static val STATE_CONNECTING: Int
State indicating the class doing playback is currently connecting to a new destination. Depending on the implementation you may return to the previous state when the connection finishes or enter STATE_NONE. If the connection failed STATE_ERROR should be used.
Value: 8See Also
STATE_ERROR
static val STATE_ERROR: Int
State indicating this item is currently in an error state. The error message should also be set when entering this state.
Value: 7See Also
STATE_FAST_FORWARDING
static val STATE_FAST_FORWARDING: Int
State indicating this item is currently fast forwarding.
Value: 4See Also
STATE_NONE
static val STATE_NONE: Int
This is the default playback state and indicates that no media has been added yet, or the performer has been reset and has no content to play.
Value: 0STATE_PAUSED
static val STATE_PAUSED: Int
State indicating this item is currently paused.
Value: 2See Also
STATE_PLAYING
static val STATE_PLAYING: Int
State indicating this item is currently playing.
Value: 3See Also
STATE_REWINDING
static val STATE_REWINDING: Int
State indicating this item is currently rewinding.
Value: 5See Also
STATE_SKIPPING_TO_NEXT
static val STATE_SKIPPING_TO_NEXT: Int
State indicating the player is currently skipping to the next item.
Value: 10See Also
STATE_SKIPPING_TO_PREVIOUS
static val STATE_SKIPPING_TO_PREVIOUS: Int
State indicating the player is currently skipping to the previous item.
Value: 9See Also
STATE_SKIPPING_TO_QUEUE_ITEM
static val STATE_SKIPPING_TO_QUEUE_ITEM: Int
State indicating the player is currently skipping to a specific item in the queue.
Value: 11See Also
STATE_STOPPED
static val STATE_STOPPED: Int
State indicating this item is currently stopped.
Value: 1See Also
Public methods
describeContents
fun describeContents(): Int
| Return | |
|---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
getActions
fun getActions(): Long
Get the current actions available on this session. This should use a bitmask of the available actions.
-
PlaybackState.ACTION_SKIP_TO_PREVIOUS -
PlaybackState.ACTION_REWIND -
PlaybackState.ACTION_PLAY -
PlaybackState.ACTION_PAUSE -
PlaybackState.ACTION_STOP -
PlaybackState.ACTION_FAST_FORWARD -
PlaybackState.ACTION_SKIP_TO_NEXT -
PlaybackState.ACTION_SEEK_TO -
PlaybackState.ACTION_SET_RATING -
PlaybackState.ACTION_PLAY_PAUSE -
PlaybackState.ACTION_PLAY_FROM_MEDIA_ID -
PlaybackState.ACTION_PLAY_FROM_SEARCH -
PlaybackState.ACTION_SKIP_TO_QUEUE_ITEM -
PlaybackState.ACTION_PLAY_FROM_URI -
PlaybackState.ACTION_PREPARE -
PlaybackState.ACTION_PREPARE_FROM_MEDIA_ID -
PlaybackState.ACTION_PREPARE_FROM_SEARCH -
PlaybackState.ACTION_PREPARE_FROM_URI -
PlaybackState.ACTION_SET_PLAYBACK_SPEED
getActiveQueueItemId
fun getActiveQueueItemId(): Long
Get the id of the currently active item in the queue. If there is no queue or a queue is not supported by the session this will be MediaSession.QueueItem.UNKNOWN_ID.
| Return | |
|---|---|
Long |
The id of the currently active item in the queue or MediaSession.QueueItem.UNKNOWN_ID. |
getBufferedPosition
fun getBufferedPosition(): Long
Get the current buffered position in ms. This is the farthest playback point that can be reached from the current position using only buffered content.
getCustomActions
fun getCustomActions(): MutableList<PlaybackState.CustomAction!>!
Get the list of custom actions.
getErrorMessage
fun getErrorMessage(): CharSequence!
Get a user readable error message. This should be set when the state is PlaybackState.STATE_ERROR.
getExtras
fun getExtras(): Bundle?
Get any custom extras that were set on this playback state.
| Return | |
|---|---|
Bundle? |
The extras for this state or null. |
getLastPositionUpdateTime
fun getLastPositionUpdateTime(): Long
Get the elapsed real time at which position was last updated. If the position has never been set this will return 0;
| Return | |
|---|---|
Long |
The last time the position was updated. |
getPlaybackSpeed
fun getPlaybackSpeed(): Float
Get the current playback speed as a multiple of normal playback. This should be negative when rewinding. A value of 1 means normal playback and 0 means paused.
| Return | |
|---|---|
Float |
The current speed of playback. |
getState
fun getState(): Int
Get the current state of playback. One of the following:
-
PlaybackState.STATE_NONE -
PlaybackState.STATE_STOPPED -
PlaybackState.STATE_PLAYING -
PlaybackState.STATE_PAUSED -
PlaybackState.STATE_FAST_FORWARDING -
PlaybackState.STATE_REWINDING -
PlaybackState.STATE_BUFFERING -
PlaybackState.STATE_ERROR -
PlaybackState.STATE_CONNECTING -
PlaybackState.STATE_SKIPPING_TO_PREVIOUS -
PlaybackState.STATE_SKIPPING_TO_NEXT -
PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM
isActive
fun isActive(): Boolean
Returns whether this is considered as an active playback state.
The playback state is considered as an active if the state is one of the following:
toString
fun toString(): String
| Return | |
|---|---|
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
| Parameters | |
|---|---|
dest |
Parcel: The Parcel in which the object should be written. This value cannot be null. |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |