Fields Summary |
---|
private static final String | TAG |
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
new destination. 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 int | STATE_SKIPPING_TO_QUEUE_ITEMState indicating the player is currently skipping to a specific item in
the queue. |
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 List | mCustomActions |
private final CharSequence | mErrorMessage |
private final long | mUpdateTime |
private final long | mActiveItemId |
private final android.os.Bundle | mExtras |
public static final Parcelable.Creator | CREATOR |
Methods Summary |
---|
public int | describeContents()
return 0;
|
private static long | getActionForRccFlag(int flag)
switch (flag) {
case RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS:
return ACTION_SKIP_TO_PREVIOUS;
case RemoteControlClient.FLAG_KEY_MEDIA_REWIND:
return ACTION_REWIND;
case RemoteControlClient.FLAG_KEY_MEDIA_PLAY:
return ACTION_PLAY;
case RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE:
return ACTION_PLAY_PAUSE;
case RemoteControlClient.FLAG_KEY_MEDIA_PAUSE:
return ACTION_PAUSE;
case RemoteControlClient.FLAG_KEY_MEDIA_STOP:
return ACTION_STOP;
case RemoteControlClient.FLAG_KEY_MEDIA_FAST_FORWARD:
return ACTION_FAST_FORWARD;
case RemoteControlClient.FLAG_KEY_MEDIA_NEXT:
return ACTION_SKIP_TO_NEXT;
case RemoteControlClient.FLAG_KEY_MEDIA_POSITION_UPDATE:
return ACTION_SEEK_TO;
case RemoteControlClient.FLAG_KEY_MEDIA_RATING:
return ACTION_SET_RATING;
}
return 0;
|
public long | getActions()Get the current actions available on this session. This should use a
bitmask of the available actions.
- {@link PlaybackState#ACTION_SKIP_TO_PREVIOUS}
- {@link PlaybackState#ACTION_REWIND}
- {@link PlaybackState#ACTION_PLAY}
- {@link PlaybackState#ACTION_PAUSE}
- {@link PlaybackState#ACTION_STOP}
- {@link PlaybackState#ACTION_FAST_FORWARD}
- {@link PlaybackState#ACTION_SKIP_TO_NEXT}
- {@link PlaybackState#ACTION_SEEK_TO}
- {@link PlaybackState#ACTION_SET_RATING}
return mActions;
|
public static long | getActionsFromRccControlFlags(int rccFlags)
long actions = 0;
long flag = 1;
while (flag <= rccFlags) {
if ((flag & rccFlags) != 0) {
actions |= getActionForRccFlag((int) flag);
}
flag = flag << 1;
}
return actions;
|
public long | getActiveQueueItemId()Get the id of the currently active item in the queue. If there is no
queue or a queue is not supported by the session this will be
{@link MediaSession.QueueItem#UNKNOWN_ID}.
return mActiveItemId;
|
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.util.List | getCustomActions()Get the list of custom actions.
return mCustomActions;
|
public java.lang.CharSequence | getErrorMessage()Get a user readable error message. This should be set when the state is
{@link PlaybackState#STATE_ERROR}.
return mErrorMessage;
|
public android.os.Bundle | getExtras()Get any custom extras that were set on this playback state.
return mExtras;
|
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 long | getPosition()Get the current playback position in ms.
return mPosition;
|
public static int | getRccControlFlagsFromActions(long actions)
int rccFlags = 0;
long action = 1;
while (action <= actions && action < Integer.MAX_VALUE) {
if ((action & actions) != 0) {
rccFlags |= getRccFlagForAction(action);
}
action = action << 1;
}
return rccFlags;
|
private static int | getRccFlagForAction(long action)
// We only care about the lower set of actions that can map to rcc
// flags.
int testAction = action < Integer.MAX_VALUE ? (int) action : 0;
switch (testAction) {
case (int) ACTION_SKIP_TO_PREVIOUS:
return RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS;
case (int) ACTION_REWIND:
return RemoteControlClient.FLAG_KEY_MEDIA_REWIND;
case (int) ACTION_PLAY:
return RemoteControlClient.FLAG_KEY_MEDIA_PLAY;
case (int) ACTION_PLAY_PAUSE:
return RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE;
case (int) ACTION_PAUSE:
return RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
case (int) ACTION_STOP:
return RemoteControlClient.FLAG_KEY_MEDIA_STOP;
case (int) ACTION_FAST_FORWARD:
return RemoteControlClient.FLAG_KEY_MEDIA_FAST_FORWARD;
case (int) ACTION_SKIP_TO_NEXT:
return RemoteControlClient.FLAG_KEY_MEDIA_NEXT;
case (int) ACTION_SEEK_TO:
return RemoteControlClient.FLAG_KEY_MEDIA_POSITION_UPDATE;
case (int) ACTION_SET_RATING:
return RemoteControlClient.FLAG_KEY_MEDIA_RATING;
}
return 0;
|
public static int | getRccStateFromState(int state)Get the {@link RemoteControlClient} state for the given
{@link PlaybackState} state.
switch (state) {
case STATE_BUFFERING:
return RemoteControlClient.PLAYSTATE_BUFFERING;
case STATE_ERROR:
return RemoteControlClient.PLAYSTATE_ERROR;
case STATE_FAST_FORWARDING:
return RemoteControlClient.PLAYSTATE_FAST_FORWARDING;
case STATE_NONE:
return RemoteControlClient.PLAYSTATE_NONE;
case STATE_PAUSED:
return RemoteControlClient.PLAYSTATE_PAUSED;
case STATE_PLAYING:
return RemoteControlClient.PLAYSTATE_PLAYING;
case STATE_REWINDING:
return RemoteControlClient.PLAYSTATE_REWINDING;
case STATE_SKIPPING_TO_PREVIOUS:
return RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS;
case STATE_SKIPPING_TO_NEXT:
return RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS;
case STATE_STOPPED:
return RemoteControlClient.PLAYSTATE_STOPPED;
default:
return -1;
}
|
public int | getState()Get the current state of playback. One of the following:
- {@link PlaybackState#STATE_NONE}
- {@link PlaybackState#STATE_STOPPED}
- {@link PlaybackState#STATE_PLAYING}
- {@link PlaybackState#STATE_PAUSED}
- {@link PlaybackState#STATE_FAST_FORWARDING}
- {@link PlaybackState#STATE_REWINDING}
- {@link PlaybackState#STATE_BUFFERING}
- {@link PlaybackState#STATE_ERROR}
return mState;
|
public static int | getStateFromRccState(int rccState)Get the {@link PlaybackState} state for the given
{@link RemoteControlClient} state.
switch (rccState) {
case RemoteControlClient.PLAYSTATE_BUFFERING:
return STATE_BUFFERING;
case RemoteControlClient.PLAYSTATE_ERROR:
return STATE_ERROR;
case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
return STATE_FAST_FORWARDING;
case RemoteControlClient.PLAYSTATE_NONE:
return STATE_NONE;
case RemoteControlClient.PLAYSTATE_PAUSED:
return STATE_PAUSED;
case RemoteControlClient.PLAYSTATE_PLAYING:
return STATE_PLAYING;
case RemoteControlClient.PLAYSTATE_REWINDING:
return STATE_REWINDING;
case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
return STATE_SKIPPING_TO_PREVIOUS;
case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
return STATE_SKIPPING_TO_NEXT;
case RemoteControlClient.PLAYSTATE_STOPPED:
return STATE_STOPPED;
default:
return -1;
}
|
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(", custom actions=").append(mCustomActions);
bob.append(", active item id=").append(mActiveItemId);
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);
dest.writeTypedList(mCustomActions);
dest.writeLong(mActiveItemId);
dest.writeCharSequence(mErrorMessage);
dest.writeBundle(mExtras);
|