public final class PlaybackState extends Object implements Parcelable
MediaSession
. This includes a state like
STATE_PLAYING
, the current playback position,
and the current control capabilities.Modifier and Type | Class and Description |
---|---|
static interface |
PlaybackState.Actions |
static class |
PlaybackState.Builder
Builder for
PlaybackState objects. |
static class |
PlaybackState.CustomAction
CustomActions can be used to extend the capabilities of
the standard transport controls by exposing app specific actions to
MediaControllers . |
static interface |
PlaybackState.State |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static long |
ACTION_FAST_FORWARD
Indicates this session supports the fast forward command.
|
static long |
ACTION_PAUSE
Indicates this session supports the pause command.
|
static long |
ACTION_PLAY
Indicates this session supports the play command.
|
static long |
ACTION_PLAY_FROM_MEDIA_ID
Indicates this session supports the play from media id command.
|
static long |
ACTION_PLAY_FROM_SEARCH
Indicates this session supports the play from search command.
|
static long |
ACTION_PLAY_FROM_URI
Indicates this session supports the play from URI command.
|
static long |
ACTION_PLAY_PAUSE
Indicates this session supports the play/pause toggle command.
|
static long |
ACTION_PREPARE
Indicates this session supports the prepare command.
|
static long |
ACTION_PREPARE_FROM_MEDIA_ID
Indicates this session supports the prepare from media id command.
|
static long |
ACTION_PREPARE_FROM_SEARCH
Indicates this session supports the prepare from search command.
|
static long |
ACTION_PREPARE_FROM_URI
Indicates this session supports the prepare from URI command.
|
static long |
ACTION_REWIND
Indicates this session supports the rewind command.
|
static long |
ACTION_SEEK_TO
Indicates this session supports the seek to command.
|
static long |
ACTION_SET_RATING
Indicates this session supports the set rating command.
|
static long |
ACTION_SKIP_TO_NEXT
Indicates this session supports the next command.
|
static long |
ACTION_SKIP_TO_PREVIOUS
Indicates this session supports the previous command.
|
static long |
ACTION_SKIP_TO_QUEUE_ITEM
Indicates this session supports the skip to queue item command.
|
static long |
ACTION_STOP
Indicates this session supports the stop command.
|
static Parcelable.Creator<PlaybackState> |
CREATOR |
static long |
PLAYBACK_POSITION_UNKNOWN
Use this value for the position to indicate the position is not known.
|
static int |
STATE_BUFFERING
State indicating this item is currently buffering and will begin playing
when enough data has buffered.
|
static int |
STATE_CONNECTING
State indicating the class doing playback is currently connecting to a
new destination.
|
static int |
STATE_ERROR
State indicating this item is currently in an error state.
|
static int |
STATE_FAST_FORWARDING
State indicating this item is currently fast forwarding.
|
static int |
STATE_NONE
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_PAUSED
State indicating this item is currently paused.
|
static int |
STATE_PLAYING
State indicating this item is currently playing.
|
static int |
STATE_REWINDING
State indicating this item is currently rewinding.
|
static int |
STATE_SKIPPING_TO_NEXT
State indicating the player is currently skipping to the next item.
|
static int |
STATE_SKIPPING_TO_PREVIOUS
State indicating the player is currently skipping to the previous item.
|
static int |
STATE_SKIPPING_TO_QUEUE_ITEM
State indicating the player is currently skipping to a specific item in
the queue.
|
static int |
STATE_STOPPED
State indicating this item is currently stopped.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
long |
getActions()
Get the current actions available on this session.
|
static long |
getActionsFromRccControlFlags(int rccFlags) |
long |
getActiveQueueItemId()
Get the id of the currently active item in the queue.
|
long |
getBufferedPosition()
Get the current buffered position in ms.
|
List<PlaybackState.CustomAction> |
getCustomActions()
Get the list of custom actions.
|
CharSequence |
getErrorMessage()
Get a user readable error message.
|
Bundle |
getExtras()
Get any custom extras that were set on this playback state.
|
long |
getLastPositionUpdateTime()
Get the elapsed real time at which position was last updated.
|
float |
getPlaybackSpeed()
Get the current playback speed as a multiple of normal playback.
|
long |
getPosition()
Get the current playback position in ms.
|
static int |
getRccControlFlagsFromActions(long actions) |
static int |
getRccStateFromState(int state)
Get the
RemoteControlClient state for the given
PlaybackState state. |
int |
getState()
Get the current state of playback.
|
static int |
getStateFromRccState(int rccState)
Get the
PlaybackState state for the given
RemoteControlClient state. |
String |
toString()
Returns a string representation of the object.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
public static final long ACTION_STOP
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PAUSE
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PLAY
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_REWIND
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_SKIP_TO_PREVIOUS
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_SKIP_TO_NEXT
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_FAST_FORWARD
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_SET_RATING
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_SEEK_TO
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PLAY_PAUSE
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PLAY_FROM_MEDIA_ID
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PLAY_FROM_SEARCH
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_SKIP_TO_QUEUE_ITEM
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PLAY_FROM_URI
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PREPARE
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PREPARE_FROM_MEDIA_ID
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PREPARE_FROM_SEARCH
Builder#setActions(long)
,
Constant Field Valuespublic static final long ACTION_PREPARE_FROM_URI
Builder#setActions(long)
,
Constant Field Valuespublic static final int STATE_NONE
Builder#setState(int, long, float)
,
Builder#setState(int, long, float, long)
,
Constant Field Valuespublic static final int STATE_STOPPED
Builder#setState
,
Constant Field Valuespublic static final int STATE_PAUSED
Builder#setState
,
Constant Field Valuespublic static final int STATE_PLAYING
Builder#setState
,
Constant Field Valuespublic static final int STATE_FAST_FORWARDING
Builder#setState
,
Constant Field Valuespublic static final int STATE_REWINDING
Builder#setState
,
Constant Field Valuespublic static final int STATE_BUFFERING
Builder#setState
,
Constant Field Valuespublic static final int STATE_ERROR
Builder#setState
,
Constant Field Valuespublic static final int STATE_CONNECTING
STATE_NONE
.
If the connection failed STATE_ERROR
should be used.Builder#setState
,
Constant Field Valuespublic static final int STATE_SKIPPING_TO_PREVIOUS
Builder#setState
,
Constant Field Valuespublic static final int STATE_SKIPPING_TO_NEXT
Builder#setState
,
Constant Field Valuespublic static final int STATE_SKIPPING_TO_QUEUE_ITEM
Builder#setState
,
Constant Field Valuespublic static final long PLAYBACK_POSITION_UNKNOWN
public static final Parcelable.Creator<PlaybackState> CREATOR
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.public int getState()
public long getPosition()
public long getBufferedPosition()
public float getPlaybackSpeed()
public long getActions()
ACTION_SKIP_TO_PREVIOUS
ACTION_REWIND
ACTION_PLAY
ACTION_PAUSE
ACTION_STOP
ACTION_FAST_FORWARD
ACTION_SKIP_TO_NEXT
ACTION_SEEK_TO
ACTION_SET_RATING
ACTION_PLAY_PAUSE
ACTION_PLAY_FROM_MEDIA_ID
ACTION_PLAY_FROM_SEARCH
ACTION_SKIP_TO_QUEUE_ITEM
ACTION_PLAY_FROM_URI
ACTION_PREPARE
ACTION_PREPARE_FROM_MEDIA_ID
ACTION_PREPARE_FROM_SEARCH
ACTION_PREPARE_FROM_URI
public List<PlaybackState.CustomAction> getCustomActions()
public CharSequence getErrorMessage()
STATE_ERROR
.public long getLastPositionUpdateTime()
public long getActiveQueueItemId()
MediaSession.QueueItem.UNKNOWN_ID
.MediaSession.QueueItem.UNKNOWN_ID
.public Bundle getExtras()
public static int getStateFromRccState(int rccState)
PlaybackState
state for the given
RemoteControlClient
state.rccState
- The state used by RemoteControlClient
.PlaybackState
.public static int getRccStateFromState(int state)
RemoteControlClient
state for the given
PlaybackState
state.state
- The state used by PlaybackState
.RemoteControlClient
.public static long getActionsFromRccControlFlags(int rccFlags)
public static int getRccControlFlagsFromActions(long actions)