Fields Summary |
---|
public static final long | ACTION_STOPIndicates this session supports the stop command. |
public static final long | ACTION_PAUSEIndicates this session supports the pause command. |
public static final long | ACTION_PLAYIndicates this session supports the play command. |
public static final long | ACTION_REWINDIndicates this session supports the rewind command. |
public static final long | ACTION_SKIP_TO_PREVIOUSIndicates this session supports the previous command. |
public static final long | ACTION_SKIP_TO_NEXTIndicates this session supports the next command. |
public static final long | ACTION_FAST_FORWARDIndicates this session supports the fast forward command. |
public static final long | ACTION_SET_RATINGIndicates this session supports the set rating command. |
public static final long | ACTION_SEEK_TOIndicates this session supports the seek to command. |
public static final long | ACTION_PLAY_PAUSEIndicates this session supports the play/pause toggle command. |
public static final long | ACTION_PLAY_FROM_MEDIA_IDIndicates this session supports the play from media id command. |
public static final long | ACTION_PLAY_FROM_SEARCHIndicates this session supports the play from search command. |
public static final long | ACTION_SKIP_TO_QUEUE_ITEMIndicates this session supports the skip to queue item command. |
public static final int | STATE_NONEThis is the default playback state and indicates that no media has been
added yet, or the performer has been reset and has no content to play. |
public static final int | STATE_STOPPEDState indicating this item is currently stopped. |
public static final int | STATE_PAUSEDState indicating this item is currently paused. |
public static final int | STATE_PLAYINGState indicating this item is currently playing. |
public static final int | STATE_FAST_FORWARDINGState indicating this item is currently fast forwarding. |
public static final int | STATE_REWINDINGState indicating this item is currently rewinding. |
public static final int | STATE_BUFFERINGState indicating this item is currently buffering and will begin playing
when enough data has buffered. |
public static final int | STATE_ERRORState indicating this item is currently in an error state. The error
message should also be set when entering this state. |
public static final int | STATE_CONNECTINGState indicating the class doing playback is currently connecting to a
route. Depending on the implementation you may return to the previous
state when the connection finishes or enter {@link #STATE_NONE}. If
the connection failed {@link #STATE_ERROR} should be used. |
public static final int | STATE_SKIPPING_TO_PREVIOUSState indicating the player is currently skipping to the previous item. |
public static final int | STATE_SKIPPING_TO_NEXTState indicating the player is currently skipping to the next item. |
public static final long | PLAYBACK_POSITION_UNKNOWNUse this value for the position to indicate the position is not known. |
private final int | mState |
private final long | mPosition |
private final long | mBufferedPosition |
private final float | mSpeed |
private final long | mActions |
private final CharSequence | mErrorMessage |
private final long | mUpdateTime |
private Object | mStateObj |
public static final Parcelable.Creator | CREATOR |
Methods Summary |
---|
public int | describeContents()
return 0;
|
public static android.support.v4.media.session.PlaybackStateCompat | fromPlaybackState(java.lang.Object stateObj)Creates an instance from a framework {@link android.media.session.PlaybackState} object.
This method is only supported on API 21+.
if (stateObj == null || Build.VERSION.SDK_INT < 21) {
return null;
}
PlaybackStateCompat state = new PlaybackStateCompat(
PlaybackStateCompatApi21.getState(stateObj),
PlaybackStateCompatApi21.getPosition(stateObj),
PlaybackStateCompatApi21.getBufferedPosition(stateObj),
PlaybackStateCompatApi21.getPlaybackSpeed(stateObj),
PlaybackStateCompatApi21.getActions(stateObj),
PlaybackStateCompatApi21.getErrorMessage(stateObj),
PlaybackStateCompatApi21.getLastPositionUpdateTime(stateObj));
state.mStateObj = stateObj;
return state;
|
public long | getActions()Get the current actions available on this session. This should use a
bitmask of the available actions.
- {@link PlaybackStateCompat#ACTION_SKIP_TO_PREVIOUS}
- {@link PlaybackStateCompat#ACTION_REWIND}
- {@link PlaybackStateCompat#ACTION_PLAY}
- {@link PlaybackStateCompat#ACTION_PAUSE}
- {@link PlaybackStateCompat#ACTION_STOP}
- {@link PlaybackStateCompat#ACTION_FAST_FORWARD}
- {@link PlaybackStateCompat#ACTION_SKIP_TO_NEXT}
- {@link PlaybackStateCompat#ACTION_SEEK_TO}
- {@link PlaybackStateCompat#ACTION_SET_RATING}
return mActions;
|
public long | getBufferedPosition()Get 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 mBufferedPosition;
|
public java.lang.CharSequence | getErrorMessage()Get a user readable error message. This should be set when the state is
{@link PlaybackStateCompat#STATE_ERROR}.
return mErrorMessage;
|
public long | getLastPositionUpdateTime()Get the elapsed real time at which position was last updated. If the
position has never been set this will return 0;
return mUpdateTime;
|
public float | getPlaybackSpeed()Get the current playback speed as a multiple of normal playback. This
should be negative when rewinding. A value of 1 means normal playback and
0 means paused.
return mSpeed;
|
public java.lang.Object | getPlaybackState()Gets the underlying framework {@link android.media.session.PlaybackState} object.
This method is only supported on API 21+.
if (mStateObj != null || Build.VERSION.SDK_INT < 21) {
return mStateObj;
}
mStateObj = PlaybackStateCompatApi21.newInstance(mState, mPosition, mBufferedPosition,
mSpeed, mActions, mErrorMessage, mUpdateTime);
return mStateObj;
|
public long | getPosition()Get the current playback position in ms.
return mPosition;
|
public int | getState()Get the current state of playback. One of the following:
- {@link PlaybackStateCompat#STATE_NONE}
- {@link PlaybackStateCompat#STATE_STOPPED}
- {@link PlaybackStateCompat#STATE_PLAYING}
- {@link PlaybackStateCompat#STATE_PAUSED}
- {@link PlaybackStateCompat#STATE_FAST_FORWARDING}
- {@link PlaybackStateCompat#STATE_REWINDING}
- {@link PlaybackStateCompat#STATE_BUFFERING}
- {@link PlaybackStateCompat#STATE_ERROR}
return mState;
|
public java.lang.String | toString()
StringBuilder bob = new StringBuilder("PlaybackState {");
bob.append("state=").append(mState);
bob.append(", position=").append(mPosition);
bob.append(", buffered position=").append(mBufferedPosition);
bob.append(", speed=").append(mSpeed);
bob.append(", updated=").append(mUpdateTime);
bob.append(", actions=").append(mActions);
bob.append(", error=").append(mErrorMessage);
bob.append("}");
return bob.toString();
|
public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mState);
dest.writeLong(mPosition);
dest.writeFloat(mSpeed);
dest.writeLong(mUpdateTime);
dest.writeLong(mBufferedPosition);
dest.writeLong(mActions);
TextUtils.writeToParcel(mErrorMessage, dest, flags);
|