Android APIs
public static final class

PlaybackStateCompat.Builder

extends Object
java.lang.Object
   ↳ android.support.v4.media.session.PlaybackStateCompat.Builder

Class Overview

Builder for PlaybackStateCompat objects.

Summary

Public Constructors
PlaybackStateCompat.Builder()
Create an empty Builder.
PlaybackStateCompat.Builder(PlaybackStateCompat source)
Create a Builder using a PlaybackStateCompat instance to set the initial values.
Public Methods
PlaybackStateCompat build()
Creates the playback state object.
PlaybackStateCompat.Builder setActions(long capabilities)
Set the current capabilities available on this session.
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 setState(int state, long position, float playbackSpeed, long updateTime)
Set the current state of playback.
PlaybackStateCompat.Builder setState(int state, long position, float playbackSpeed)
Set the current state of playback.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PlaybackStateCompat.Builder ()

Create an empty Builder.

public PlaybackStateCompat.Builder (PlaybackStateCompat source)

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

Parameters
source The playback state to copy.

Public Methods

public PlaybackStateCompat build ()

Creates the playback state object.

public PlaybackStateCompat.Builder setActions (long capabilities)

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

Returns
  • this

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

Returns
  • this

public PlaybackStateCompat.Builder setErrorMessage (CharSequence errorMessage)

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

Returns
  • this

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

Parameters
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 elapsedRealtime() timebase that the position was updated at.
Returns
  • this

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

Parameters
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.