belongs to Maven artifact com.android.support:support-media-compat:28.0.0-alpha1
PlaybackStateCompat.Builder
public
static
final
class
PlaybackStateCompat.Builder
extends Object
java.lang.Object | |
↳ | android.support.v4.media.session.PlaybackStateCompat.Builder |
Builder for PlaybackStateCompat
objects.
Summary
Public constructors | |
---|---|
PlaybackStateCompat.Builder()
Create an empty Builder. |
|
PlaybackStateCompat.Builder(PlaybackStateCompat source)
Create a Builder using a |
Public methods | |
---|---|
PlaybackStateCompat.Builder
|
addCustomAction(String action, String name, int icon)
Add a custom action to the playback state. |
PlaybackStateCompat.Builder
|
addCustomAction(PlaybackStateCompat.CustomAction customAction)
Add a custom action to the playback state. |
PlaybackStateCompat
|
build()
Creates the playback state object. |
PlaybackStateCompat.Builder
|
setActions(long capabilities)
Set the current capabilities available on this session. |
PlaybackStateCompat.Builder
|
setActiveQueueItemId(long id)
Set the active item in the play queue by specifying its id. |
PlaybackStateCompat.Builder
|
setBufferedPosition(long bufferPosition)
Set the current buffered position in ms. |
PlaybackStateCompat.Builder
|
setErrorMessage(CharSequence errorMessage)
This method was deprecated
in API level 25.4.0.
Use |
PlaybackStateCompat.Builder
|
setErrorMessage(int errorCode, CharSequence errorMessage)
Set the error code with an optional user readable error message. |
PlaybackStateCompat.Builder
|
setExtras(Bundle extras)
Set any custom extras to be included with the playback state. |
PlaybackStateCompat.Builder
|
setState(int state, long position, float playbackSpeed)
Set the current state of playback. |
PlaybackStateCompat.Builder
|
setState(int state, long position, float playbackSpeed, long updateTime)
Set the current state of playback. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
Public constructors
PlaybackStateCompat.Builder
PlaybackStateCompat.Builder ()
Create an empty Builder.
PlaybackStateCompat.Builder
PlaybackStateCompat.Builder (PlaybackStateCompat source)
Create a Builder using a PlaybackStateCompat
instance to set the
initial values.
Parameters | |
---|---|
source |
PlaybackStateCompat : The playback state to copy.
|
Public methods
addCustomAction
PlaybackStateCompat.Builder addCustomAction (String action, String name, int icon)
Add a custom action to the playback state. Actions can be used to
expose additional functionality to Controllers
beyond what is offered by the standard transport
controls.
e.g. start a radio station based on the current item or skip ahead by 30 seconds.
Parameters | |
---|---|
action |
String : An identifier for this action. It can be sent back to
the MediaSessionCompat through
sendCustomAction(String, Bundle) . |
name |
String : The display name for the action. If text is shown with
the action or used for accessibility, this is what should
be used. |
icon |
int : The resource action of the icon that should be displayed
for the action. The resource should be in the package of
the MediaSessionCompat . |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
addCustomAction
PlaybackStateCompat.Builder addCustomAction (PlaybackStateCompat.CustomAction customAction)
Add a custom action to the playback state. Actions can be used to expose additional
functionality to Controllers
beyond what is offered
by the standard transport controls.
An example of an action would be to start a radio station based on the current item or to skip ahead by 30 seconds.
Parameters | |
---|---|
customAction |
PlaybackStateCompat.CustomAction : The custom action to add to the PlaybackStateCompat . |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
build
PlaybackStateCompat build ()
Creates the playback state object.
Returns | |
---|---|
PlaybackStateCompat |
setActions
PlaybackStateCompat.Builder setActions (long capabilities)
Set the current capabilities available on this session. This should use a bitmask of the available capabilities.
-
ACTION_SKIP_TO_PREVIOUS
-
ACTION_REWIND
-
ACTION_PLAY
-
ACTION_PLAY_PAUSE
-
ACTION_PAUSE
-
ACTION_STOP
-
ACTION_FAST_FORWARD
-
ACTION_SKIP_TO_NEXT
-
ACTION_SEEK_TO
-
ACTION_SET_RATING
-
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
-
ACTION_SET_REPEAT_MODE
-
ACTION_SET_SHUFFLE_MODE
-
ACTION_SET_CAPTIONING_ENABLED
Parameters | |
---|---|
capabilities |
long |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
setActiveQueueItemId
PlaybackStateCompat.Builder setActiveQueueItemId (long id)
Set the active item in the play queue by specifying its id. The
default value is UNKNOWN_ID
Parameters | |
---|---|
id |
long : The id of the active item. |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
setBufferedPosition
PlaybackStateCompat.Builder setBufferedPosition (long bufferPosition)
Set the current buffered position in ms. This is the farthest playback point that can be reached from the current position using only buffered content.
Parameters | |
---|---|
bufferPosition |
long |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
setErrorMessage
PlaybackStateCompat.Builder setErrorMessage (CharSequence errorMessage)
This method was deprecated
in API level 25.4.0.
Use setErrorMessage(int, CharSequence)
instead.
Set a user readable error message. This should be set when the state
is STATE_ERROR
.
Parameters | |
---|---|
errorMessage |
CharSequence |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
setErrorMessage
PlaybackStateCompat.Builder setErrorMessage (int errorCode, CharSequence errorMessage)
Set the error code with an optional user readable error message. This should be set when
the state is STATE_ERROR
.
Parameters | |
---|---|
errorCode |
int : The errorCode to set. |
errorMessage |
CharSequence : The user readable error message. Can be null. |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
setExtras
PlaybackStateCompat.Builder setExtras (Bundle extras)
Set any custom extras to be included with the playback state.
Parameters | |
---|---|
extras |
Bundle : The extras to include. |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
setState
PlaybackStateCompat.Builder setState (int state, long position, float playbackSpeed)
Set the current state of playback.
The position must be in ms and indicates the current playback
position within the track. If the position is unknown use
PLAYBACK_POSITION_UNKNOWN
.
The rate is a multiple of normal playback and should be 0 when paused and negative when rewinding. Normal playback rate is 1.0.
The state must be one of the following:
-
STATE_NONE
-
STATE_STOPPED
-
STATE_PLAYING
-
STATE_PAUSED
-
STATE_FAST_FORWARDING
-
STATE_REWINDING
-
STATE_BUFFERING
-
STATE_ERROR
-
STATE_CONNECTING
-
STATE_SKIPPING_TO_PREVIOUS
-
STATE_SKIPPING_TO_NEXT
-
STATE_SKIPPING_TO_QUEUE_ITEM
Parameters | |
---|---|
state |
int : The current state of playback. |
position |
long : The position in the current track in ms. |
playbackSpeed |
float : The current rate of playback as a multiple of
normal playback.
|
Returns | |
---|---|
PlaybackStateCompat.Builder |
setState
PlaybackStateCompat.Builder setState (int state, long position, float playbackSpeed, long updateTime)
Set the current state of playback.
The position must be in ms and indicates the current playback
position within the track. If the position is unknown use
PLAYBACK_POSITION_UNKNOWN
.
The rate is a multiple of normal playback and should be 0 when paused and negative when rewinding. Normal playback rate is 1.0.
The state must be one of the following:
-
STATE_NONE
-
STATE_STOPPED
-
STATE_PLAYING
-
STATE_PAUSED
-
STATE_FAST_FORWARDING
-
STATE_REWINDING
-
STATE_BUFFERING
-
STATE_ERROR
-
STATE_CONNECTING
-
STATE_SKIPPING_TO_PREVIOUS
-
STATE_SKIPPING_TO_NEXT
-
STATE_SKIPPING_TO_QUEUE_ITEM
Parameters | |
---|---|
state |
int : The current state of playback. |
position |
long : The position in the current item in ms. |
playbackSpeed |
float : The current speed of playback as a multiple of
normal playback. |
updateTime |
long : The time in the elapsedRealtime()
timebase that the position was updated at. |
Returns | |
---|---|
PlaybackStateCompat.Builder |
this |
Interfaces
Classes
- MediaButtonReceiver
- MediaControllerCompat
- MediaControllerCompat.Callback
- MediaControllerCompat.PlaybackInfo
- MediaControllerCompat.TransportControls
- MediaSessionCompat
- MediaSessionCompat.Callback
- MediaSessionCompat.QueueItem
- MediaSessionCompat.Token
- ParcelableVolumeInfo
- PlaybackStateCompat
- PlaybackStateCompat.Builder
- PlaybackStateCompat.CustomAction
- PlaybackStateCompat.CustomAction.Builder