public static final class PlaybackStateCompat.Builder extends Object
PlaybackStateCompat
objects.Constructor and Description |
---|
Builder()
Create an empty Builder.
|
Builder(PlaybackStateCompat source)
Create a Builder using a
PlaybackStateCompat instance to set the
initial values. |
Modifier and Type | Method and Description |
---|---|
PlaybackStateCompat.Builder |
addCustomAction(PlaybackStateCompat.CustomAction customAction)
Add a custom action to the playback state.
|
PlaybackStateCompat.Builder |
addCustomAction(String action,
String name,
int icon)
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)
Set a 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.
|
public Builder()
public Builder(PlaybackStateCompat source)
PlaybackStateCompat
instance to set the
initial values.source
- The playback state to copy.public PlaybackStateCompat.Builder setState(int state, long position, float playbackSpeed)
The position must be in ms and indicates the current playback
position within the track. If the position is unknown use
PlaybackStateCompat.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:
PlaybackStateCompat.STATE_NONE
PlaybackStateCompat.STATE_STOPPED
PlaybackStateCompat.STATE_PLAYING
PlaybackStateCompat.STATE_PAUSED
PlaybackStateCompat.STATE_FAST_FORWARDING
PlaybackStateCompat.STATE_REWINDING
PlaybackStateCompat.STATE_BUFFERING
PlaybackStateCompat.STATE_ERROR
PlaybackStateCompat.STATE_CONNECTING
PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS
PlaybackStateCompat.STATE_SKIPPING_TO_NEXT
PlaybackStateCompat.STATE_SKIPPING_TO_QUEUE_ITEM
state
- The current state of playback.position
- The position in the current track in ms.playbackSpeed
- The current rate of playback as a multiple of
normal playback.public PlaybackStateCompat.Builder setState(int state, long position, float playbackSpeed, long updateTime)
The position must be in ms and indicates the current playback
position within the track. If the position is unknown use
PlaybackStateCompat.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:
PlaybackStateCompat.STATE_NONE
PlaybackStateCompat.STATE_STOPPED
PlaybackStateCompat.STATE_PLAYING
PlaybackStateCompat.STATE_PAUSED
PlaybackStateCompat.STATE_FAST_FORWARDING
PlaybackStateCompat.STATE_REWINDING
PlaybackStateCompat.STATE_BUFFERING
PlaybackStateCompat.STATE_ERROR
PlaybackStateCompat.STATE_CONNECTING
PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS
PlaybackStateCompat.STATE_SKIPPING_TO_NEXT
PlaybackStateCompat.STATE_SKIPPING_TO_QUEUE_ITEM
state
- The current state of playback.position
- The position in the current item in ms.playbackSpeed
- The current speed of playback as a multiple of
normal playback.updateTime
- The time in the SystemClock.elapsedRealtime()
timebase that the position was updated at.public PlaybackStateCompat.Builder setBufferedPosition(long bufferPosition)
public PlaybackStateCompat.Builder setActions(long capabilities)
PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS
PlaybackStateCompat.ACTION_REWIND
PlaybackStateCompat.ACTION_PLAY
PlaybackStateCompat.ACTION_PLAY_PAUSE
PlaybackStateCompat.ACTION_PAUSE
PlaybackStateCompat.ACTION_STOP
PlaybackStateCompat.ACTION_FAST_FORWARD
PlaybackStateCompat.ACTION_SKIP_TO_NEXT
PlaybackStateCompat.ACTION_SEEK_TO
PlaybackStateCompat.ACTION_SET_RATING
PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID
PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH
PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM
PlaybackStateCompat.ACTION_PLAY_FROM_URI
PlaybackStateCompat.ACTION_PREPARE
PlaybackStateCompat.ACTION_PREPARE_FROM_MEDIA_ID
PlaybackStateCompat.ACTION_PREPARE_FROM_SEARCH
PlaybackStateCompat.ACTION_PREPARE_FROM_URI
public PlaybackStateCompat.Builder addCustomAction(String action, String name, int icon)
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.
action
- An identifier for this action. It can be sent back to
the MediaSessionCompat
through
MediaControllerCompat.TransportControls.sendCustomAction(String, Bundle)
.name
- The display name for the action. If text is shown with
the action or used for accessibility, this is what should
be used.icon
- The resource action of the icon that should be displayed
for the action. The resource should be in the package of
the MediaSessionCompat
.public PlaybackStateCompat.Builder addCustomAction(PlaybackStateCompat.CustomAction customAction)
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.
customAction
- The custom action to add to the PlaybackStateCompat
.public PlaybackStateCompat.Builder setActiveQueueItemId(long id)
MediaSessionCompat.QueueItem.UNKNOWN_ID
id
- The id of the active item.public PlaybackStateCompat.Builder setErrorMessage(CharSequence errorMessage)
PlaybackStateCompat.STATE_ERROR
.public PlaybackStateCompat.Builder setExtras(Bundle extras)
extras
- The extras to include.public PlaybackStateCompat build()