Builder
class Builder
kotlin.Any | |
↳ | android.support.v4.media.session.PlaybackStateCompat.Builder |
Builder for PlaybackStateCompat
objects.
Summary
Public constructors |
|
---|---|
<init>() Create an empty Builder. |
|
<init>(source: PlaybackStateCompat!) Create a Builder using a |
Public methods |
|
---|---|
PlaybackStateCompat.Builder! |
addCustomAction(action: String!, name: String!, icon: Int) Add a custom action to the playback state. |
PlaybackStateCompat.Builder! |
addCustomAction(customAction: PlaybackStateCompat.CustomAction!) Add a custom action to the playback state. |
PlaybackStateCompat! |
build() Creates the playback state object. |
PlaybackStateCompat.Builder! |
setActions(capabilities: Long) Set the current capabilities available on this session. |
PlaybackStateCompat.Builder! |
setActiveQueueItemId(id: Long) Set the active item in the play queue by specifying its id. |
PlaybackStateCompat.Builder! |
setBufferedPosition(bufferPosition: Long) Set the current buffered position in ms. |
PlaybackStateCompat.Builder! |
setErrorMessage(errorMessage: CharSequence!) Set a user readable error message. |
PlaybackStateCompat.Builder! |
setErrorMessage(errorCode: Int, errorMessage: CharSequence!) Set the error code with an optional user readable error message. |
PlaybackStateCompat.Builder! |
Set any custom extras to be included with the playback state. |
PlaybackStateCompat.Builder! |
Set the current state of playback. |
PlaybackStateCompat.Builder! |
Set the current state of playback. |
Public constructors
<init>
Builder()
Create an empty Builder.
<init>
Builder(source: PlaybackStateCompat!)
Create a Builder using a PlaybackStateCompat
instance to set the initial values.
Parameters | |
---|---|
source |
PlaybackStateCompat!: The playback state to copy. |
Public methods
addCustomAction
fun addCustomAction(action: String!, name: String!, icon: Int): PlaybackStateCompat.Builder!
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 MediaControllerCompat.TransportControls#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 |
String!: The resource action of the icon that should be displayed for the action. The resource should be in the package of the MediaSessionCompat . |
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
addCustomAction
fun addCustomAction(customAction: PlaybackStateCompat.CustomAction!): PlaybackStateCompat.Builder!
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 . |
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
setActions
fun setActions(capabilities: Long): PlaybackStateCompat.Builder!
Set the current capabilities available on this session. This should use a bitmask of the available 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
-
PlaybackStateCompat#ACTION_SET_REPEAT_MODE
-
PlaybackStateCompat#ACTION_SET_SHUFFLE_MODE
-
PlaybackStateCompat#ACTION_SET_CAPTIONING_ENABLED
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
setActiveQueueItemId
fun setActiveQueueItemId(id: Long): PlaybackStateCompat.Builder!
Set the active item in the play queue by specifying its id. The default value is MediaSessionCompat.QueueItem#UNKNOWN_ID
Parameters | |
---|---|
id |
Long: The id of the active item. |
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
setBufferedPosition
fun setBufferedPosition(bufferPosition: Long): PlaybackStateCompat.Builder!
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.
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
setErrorMessage
funsetErrorMessage(errorMessage: CharSequence!): PlaybackStateCompat.Builder!
Deprecated: Use setErrorMessage(int, CharSequence)
instead.
Set a user readable error message. This should be set when the state is PlaybackStateCompat#STATE_ERROR
.
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
setErrorMessage
fun setErrorMessage(errorCode: Int, errorMessage: CharSequence!): PlaybackStateCompat.Builder!
Set the error code with an optional user readable error message. This should be set when the state is PlaybackStateCompat#STATE_ERROR
.
Parameters | |
---|---|
errorCode |
Int: The errorCode to set. |
errorMessage |
Int: The user readable error message. Can be null. |
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
setExtras
fun setExtras(extras: Bundle!): PlaybackStateCompat.Builder!
Set any custom extras to be included with the playback state.
Parameters | |
---|---|
extras |
Bundle!: The extras to include. |
Return | |
---|---|
PlaybackStateCompat.Builder!: this |
setState
fun setState(state: Int, position: Long, playbackSpeed: Float): PlaybackStateCompat.Builder!
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:
-
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
Parameters | |
---|---|
state |
Int: The current state of playback. |
position |
Int: The position in the current track in ms. |
playbackSpeed |
Int: The current rate of playback as a multiple of normal playback. |
setState
fun setState(state: Int, position: Long, playbackSpeed: Float, updateTime: Long): PlaybackStateCompat.Builder!
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:
-
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
Parameters | |
---|---|
state |
Int: The current state of playback. |
position |
Int: The position in the current item in ms. |
playbackSpeed |
Int: The current speed of playback as a multiple of normal playback. |
updateTime |
Int: The time in the SystemClock#elapsedRealtime timebase that the position was updated at. |
Return | |
---|---|
PlaybackStateCompat.Builder!: this |