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

Builder()

Create an empty Builder.

Builder(PlaybackStateCompat source)

Create a Builder using a PlaybackStateCompat instance to set the initial values.

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 is deprecated. Use setErrorMessage(int, CharSequence) instead.

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

Public constructors

Builder

public Builder ()

Create an empty Builder.

Builder

public 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

public 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 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 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

public 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

public