# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# PlaybackState.Builder

`public static final class PlaybackState.Builder`
`extends Object` ``

java.lang.Object
↳ | android.media.session.PlaybackState.Builder

Builder for `PlaybackState` objects.

## Summary

### Public constructors
`Builder()` Creates an initially empty state builder.
`Builder(PlaybackState from)` Creates a builder with the same initial values as those in the from state.

### Public methods
`PlaybackState.Builder` | `addCustomAction(String action, String name, int icon)` Add a custom action to the playback state.
`PlaybackState.Builder` | `addCustomAction(PlaybackState.CustomAction customAction)` Add a custom action to the playback state.
`PlaybackState` | `build()` Build and return the `PlaybackState` instance with these values.
`PlaybackState.Builder` | `setActions(long actions)` Set the current actions available on this session.
`PlaybackState.Builder` | `setActiveQueueItemId(long id)` Set the active item in the play queue by specifying its id.
`PlaybackState.Builder` | `setBufferedPosition(long bufferedPosition)` Set the current buffered position in ms.
`PlaybackState.Builder` | `setErrorMessage(CharSequence error)` Set a user readable error message.
`PlaybackState.Builder` | `setExtras(Bundle extras)` Set any custom extras to be included with the playback state.
`PlaybackState.Builder` | `setState(int state, long position, float playbackSpeed)` Set the current state of playback.
`PlaybackState.Builder` | `setState(int state, long position, float playbackSpeed, long updateTime)` Set the current state of playback.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### Builder

    public Builder ()

Creates an initially empty state builder.

### Builder

    public Builder (PlaybackState from)

Creates a builder with the same initial values as those in the from state.

Parameters
`from` | `PlaybackState`: The state to use for initializing the builder.

## Public methods

### addCustomAction

    public PlaybackState.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 `MediaControllers` 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 `MediaSession` through `MediaController.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 `MediaSession`.

Returns
`PlaybackState.Builder` | this

### addCustomAction

    public PlaybackState.Builder addCustomAction (PlaybackState.CustomAction customAction)

Add a custom action to the playback state. Actions can be used to expose additional functionality to `MediaControllers` 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` | `PlaybackState.CustomAction`: The custom action to add to the `PlaybackState`.

Returns
`PlaybackState.Builder` | this

### build

    public PlaybackState build ()

Build and return the `PlaybackState` instance with these values.

Returns
`PlaybackState` | A new state instance.

### setActions

    public PlaybackState.Builder setActions (long actions)

Set the current actions available on this session. This should use a bitmask of possible actions.

- `PlaybackState#ACTION_SKIP_TO_PREVIOUS`
- `PlaybackState#ACTION_REWIND`
- `PlaybackState#ACTION_PLAY`
- `PlaybackState#ACTION_PAUSE`
- `PlaybackState#ACTION_STOP`
- `PlaybackState#ACTION_FAST_FORWARD`
- `PlaybackState#ACTION_SKIP_TO_NEXT`
- `PlaybackState#ACTION_SEEK_TO`
- `PlaybackState#ACTION_SET_RATING`
- `PlaybackState#ACTION_PLAY_PAUSE`
- `PlaybackState#ACTION_PLAY_FROM_MEDIA_ID`
- `PlaybackState#ACTION_PLAY_FROM_SEARCH`
- `PlaybackState#ACTION_SKIP_TO_QUEUE_ITEM`
- `PlaybackState#ACTION_PLAY_FROM_URI`
- `PlaybackState#ACTION_PREPARE`
- `PlaybackState#ACTION_PREPARE_FROM_MEDIA_ID`
- `PlaybackState#ACTION_PREPARE_FROM_SEARCH`
- `PlaybackState#ACTION_PREPARE_FROM_URI`
- `PlaybackState#ACTION_SET_PLAYBACK_SPEED`

Parameters
`actions` | `long`: The set of actions allowed. Value is either `0` or a combination of `PlaybackState.ACTION_STOP`, `PlaybackState.ACTION_PAUSE`, `PlaybackState.ACTION_PLAY`, `PlaybackState.ACTION_REWIND`, `PlaybackState.ACTION_SKIP_TO_PREVIOUS`, `PlaybackState.ACTION_SKIP_TO_NEXT`, `PlaybackState.ACTION_FAST_FORWARD`, `PlaybackState.ACTION_SET_RATING`, `PlaybackState.ACTION_SEEK_TO`, `PlaybackState.ACTION_PLAY_PAUSE`, `PlaybackState.ACTION_PLAY_FROM_MEDIA_ID`, `PlaybackState.ACTION_PLAY_FROM_SEARCH`, `PlaybackState.ACTION_SKIP_TO_QUEUE_ITEM`, `PlaybackState.ACTION_PLAY_FROM_URI`, `PlaybackState.ACTION_PREPARE`, `PlaybackState.ACTION_PREPARE_FROM_MEDIA_ID`, `PlaybackState.ACTION_PREPARE_FROM_SEARCH`, `PlaybackState.ACTION_PREPARE_FROM_URI`, and `PlaybackState.ACTION_SET_PLAYBACK_SPEED`

Returns
`PlaybackState.Builder` | this

### setActiveQueueItemId

    public PlaybackState.Builder setActiveQueueItemId (long id)

Set the active item in the play queue by specifying its id. The default value is `MediaSession.QueueItem#UNKNOWN_ID`

Parameters
`id` | `long`: The id of the active item.

Returns
`PlaybackState.Builder` | this

### setBufferedPosition

    public PlaybackState.Builder setBufferedPosition (long bufferedPosition)

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
`bufferedPosition` | `long`: The position in ms that playback is buffered to.

Returns
`PlaybackState.Builder` | this

### setErrorMessage

    public PlaybackState.Builder setErrorMessage (CharSequence error)

Set a user readable error message. This should be set when the state is `PlaybackState#STATE_ERROR`.

Parameters
`error` | `CharSequence`: The error message for display to the user.

Returns
`PlaybackState.Builder` | this

### setExtras

    public PlaybackState.Builder setExtras (Bundle extras)

Set any custom extras to be included with the playback state.

Parameters
`extras` | `Bundle`: The extras to include.

Returns
`PlaybackState.Builder` | this

### setState

    public PlaybackState.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 item. If the position is unknown use `PlaybackState.PLAYBACK_POSITION_UNKNOWN`. The update time will be set to the current `SystemClock#elapsedRealtime()`.

The speed is a multiple of normal playback and should be 0 when paused and negative when rewinding. Normal playback speed is 1.0.

The state must be one of the following:

- `PlaybackState#STATE_NONE`
- `PlaybackState#STATE_STOPPED`
- `PlaybackState#STATE_PLAYING`
- `PlaybackState#STATE_PAUSED`
- `PlaybackState#STATE_FAST_FORWARDING`
- `PlaybackState#STATE_REWINDING`
- `PlaybackState#STATE_BUFFERING`
- `PlaybackState#STATE_ERROR`
- `PlaybackState#STATE_CONNECTING`
- `PlaybackState#STATE_SKIPPING_TO_PREVIOUS`
- `PlaybackState#STATE_SKIPPING_TO_NEXT`
- `PlaybackState#STATE_SKIPPING_TO_QUEUE_ITEM`

Parameters
`state` | `int`: The current state of playback. Value is `PlaybackState.STATE_NONE`, `PlaybackState.STATE_STOPPED`, `PlaybackState.STATE_PAUSED`, `PlaybackState.STATE_PLAYING`, `PlaybackState.STATE_FAST_FORWARDING`, `PlaybackState.STATE_REWINDING`, `PlaybackState.STATE_BUFFERING`, `PlaybackState.STATE_ERROR`, `PlaybackState.STATE_CONNECTING`, `PlaybackState.STATE_SKIPPING_TO_PREVIOUS`, `PlaybackState.STATE_SKIPPING_TO_NEXT`, or `PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM`
`position` | `long`: The position in the current item in ms.
`playbackSpeed` | `float`: The current speed of playback as a multiple of normal playback.

Returns
`PlaybackState.Builder` | this

### setState

    public PlaybackState.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 item. If the position is unknown use `PlaybackState.PLAYBACK_POSITION_UNKNOWN`. When not using an unknown position the time at which the position was updated must be provided. It is okay to use `SystemClock#elapsedRealtime()` if the current position was just retrieved.

The speed is a multiple of normal playback and should be 0 when paused and negative when rewinding. Normal playback speed is 1.0.

The state must be one of the following:

- `PlaybackState#STATE_NONE`
- `PlaybackState#STATE_STOPPED`
- `PlaybackState#STATE_PLAYING`
- `PlaybackState#STATE_PAUSED`
- `PlaybackState#STATE_FAST_FORWARDING`
- `PlaybackState#STATE_REWINDING`
- `PlaybackState#STATE_BUFFERING`
- `PlaybackState#STATE_ERROR`
- `PlaybackState#STATE_CONNECTING`
- `PlaybackState#STATE_SKIPPING_TO_PREVIOUS`
- `PlaybackState#STATE_SKIPPING_TO_NEXT`
- `PlaybackState#STATE_SKIPPING_TO_QUEUE_ITEM`

Parameters
`state` | `int`: The current state of playback. Value is `PlaybackState.STATE_NONE`, `PlaybackState.STATE_STOPPED`, `PlaybackState.STATE_PAUSED`, `PlaybackState.STATE_PLAYING`, `PlaybackState.STATE_FAST_FORWARDING`, `PlaybackState.STATE_REWINDING`, `PlaybackState.STATE_BUFFERING`, `PlaybackState.STATE_ERROR`, `PlaybackState.STATE_CONNECTING`, `PlaybackState.STATE_SKIPPING_TO_PREVIOUS`, `PlaybackState.STATE_SKIPPING_TO_NEXT`, or `PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM`
`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 `SystemClock#elapsedRealtime` timebase that the position was updated at.

Returns
`PlaybackState.Builder` | this

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*