List of usage examples for android.support.v4.media.session PlaybackStateCompat ACTION_SET_SHUFFLE_MODE
long ACTION_SET_SHUFFLE_MODE
To view the source code for android.support.v4.media.session PlaybackStateCompat ACTION_SET_SHUFFLE_MODE.
Click Source Link
From source file:android.support.v17.leanback.media.MediaControllerAdapter.java
@Override public long getSupportedActions() { long supportedActions = 0; if (mController.getPlaybackState() == null) { return supportedActions; }/*w w w. j a v a2s. c o m*/ long actionsFromController = mController.getPlaybackState().getActions(); // Translation. if ((actionsFromController & PlaybackStateCompat.ACTION_PLAY_PAUSE) != 0) { supportedActions |= ACTION_PLAY_PAUSE; } if ((actionsFromController & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) != 0) { supportedActions |= ACTION_SKIP_TO_NEXT; } if ((actionsFromController & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) != 0) { supportedActions |= ACTION_SKIP_TO_PREVIOUS; } if ((actionsFromController & PlaybackStateCompat.ACTION_FAST_FORWARD) != 0) { supportedActions |= ACTION_FAST_FORWARD; } if ((actionsFromController & PlaybackStateCompat.ACTION_REWIND) != 0) { supportedActions |= ACTION_REWIND; } if ((actionsFromController & PlaybackStateCompat.ACTION_SET_REPEAT_MODE) != 0) { supportedActions |= ACTION_REPEAT; } if ((actionsFromController & PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE) != 0) { supportedActions |= ACTION_SHUFFLE; } return supportedActions; }
From source file:com.example.android.leanback.PlaybackTransportControlGlueSample.java
/** * Get supported actions from player adapter then translate it into playback state compat * related actions/*from w ww. ja va 2s. com*/ */ private long getPlaybackStateActions() { long supportedActions = 0L; long actionsFromPlayerAdapter = getPlayerAdapter().getSupportedActions(); if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_SKIP_TO_PREVIOUS) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_SKIP_TO_NEXT) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_REWIND) != 0) { supportedActions |= PlaybackStateCompat.ACTION_REWIND; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_FAST_FORWARD) != 0) { supportedActions |= PlaybackStateCompat.ACTION_FAST_FORWARD; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_PLAY_PAUSE) != 0) { supportedActions |= PlaybackStateCompat.ACTION_PLAY_PAUSE; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_REPEAT) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SET_REPEAT_MODE; } else if ((actionsFromPlayerAdapter & PlaybackBaseControlGlue.ACTION_SHUFFLE) != 0) { supportedActions |= PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE; } return supportedActions; }
From source file:com.scooter1556.sms.android.activity.FullScreenPlayerActivity.java
private void updatePlaybackState(PlaybackStateCompat state) { if (state == null) { return;//from w ww .ja v a 2s . com } lastPlaybackState = state; if (mediaController != null && mediaController.getExtras() != null) { String castName = mediaController.getExtras().getString(MediaService.EXTRA_CONNECTED_CAST); String extraInfo = castName == null ? "" : getResources().getString(R.string.cast_to_device, castName); extra.setText(extraInfo); } switch (state.getState()) { case PlaybackStateCompat.STATE_PLAYING: loading.setVisibility(INVISIBLE); playPause.setVisibility(VISIBLE); playPause.setImageDrawable(pauseDrawable); controllers.setVisibility(VISIBLE); scheduleSeekbarUpdate(); break; case PlaybackStateCompat.STATE_PAUSED: controllers.setVisibility(VISIBLE); loading.setVisibility(INVISIBLE); playPause.setVisibility(VISIBLE); playPause.setImageDrawable(playDrawable); stopSeekbarUpdate(); break; case PlaybackStateCompat.STATE_NONE: case PlaybackStateCompat.STATE_STOPPED: loading.setVisibility(INVISIBLE); playPause.setVisibility(VISIBLE); playPause.setImageDrawable(playDrawable); stopSeekbarUpdate(); break; case PlaybackStateCompat.STATE_BUFFERING: playPause.setVisibility(INVISIBLE); loading.setVisibility(VISIBLE); extra.setText(R.string.state_loading); stopSeekbarUpdate(); break; default: Log.d(TAG, "Unhandled state: " + state.getState()); } skipNext.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_NEXT) == 0 ? INVISIBLE : VISIBLE); skipPrev.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) == 0 ? INVISIBLE : VISIBLE); shuffle.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE) == 0 ? INVISIBLE : VISIBLE); repeat.setVisibility( (state.getActions() & PlaybackStateCompat.ACTION_SET_REPEAT_MODE) == 0 ? INVISIBLE : VISIBLE); // Custom Actions for (PlaybackStateCompat.CustomAction action : state.getCustomActions()) { switch (action.getAction()) { case MediaService.STATE_SHUFFLE_ON: shuffle.setColorFilter(ContextCompat.getColor(getBaseContext(), R.color.accent)); break; case MediaService.STATE_SHUFFLE_OFF: shuffle.clearColorFilter(); break; case MediaService.STATE_REPEAT_NONE: repeat.setImageResource(R.drawable.ic_repeat_white_24dp); repeat.clearColorFilter(); break; case MediaService.STATE_REPEAT_ALL: repeat.setImageResource(R.drawable.ic_repeat_white_24dp); repeat.setColorFilter(ContextCompat.getColor(getBaseContext(), R.color.accent)); break; case MediaService.STATE_REPEAT_ONE: repeat.setImageResource(R.drawable.ic_repeat_one_white_24dp); repeat.setColorFilter(ContextCompat.getColor(getBaseContext(), R.color.accent)); break; } } }
From source file:com.example.android.leanback.MediaSessionService.java
/** * Return supported actions related to current playback state. * Currently the return value from this function is a constant. * For demonstration purpose, the customized fast forward action and customized rewind action * are supported in our case./*from www .j av a 2 s .com*/ * * @return playback state actions. */ private long getPlaybackStateActions() { long res = PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS | PlaybackStateCompat.ACTION_FAST_FORWARD | PlaybackStateCompat.ACTION_REWIND | PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE | PlaybackStateCompat.ACTION_SET_REPEAT_MODE; return res; }
From source file:androidx.media.MediaSession2ImplBase.java
@Override PlaybackStateCompat getPlaybackStateCompat() { synchronized (mLock) { int state = MediaUtils2.createPlaybackStateCompatState(getPlayerState(), getBufferingState()); // TODO: Consider following missing stuff // - setCustomAction(): Fill custom layout // - setErrorMessage(): Fill error message when notifyError() is called. // - setActiveQueueItemId(): Fill here with the current media item... // - setExtra(): No idea at this moment. // TODO: generate actions from the allowed commands. long allActions = PlaybackStateCompat.ACTION_STOP | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_REWIND | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_FAST_FORWARD | PlaybackStateCompat.ACTION_SET_RATING | PlaybackStateCompat.ACTION_SEEK_TO | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID | PlaybackStateCompat.ACTION_PLAY_FROM_SEARCH | PlaybackStateCompat.ACTION_SKIP_TO_QUEUE_ITEM | PlaybackStateCompat.ACTION_PLAY_FROM_URI | PlaybackStateCompat.ACTION_PREPARE | PlaybackStateCompat.ACTION_PREPARE_FROM_MEDIA_ID | PlaybackStateCompat.ACTION_PREPARE_FROM_SEARCH | PlaybackStateCompat.ACTION_PREPARE_FROM_URI | PlaybackStateCompat.ACTION_SET_REPEAT_MODE | PlaybackStateCompat.ACTION_SET_SHUFFLE_MODE | PlaybackStateCompat.ACTION_SET_CAPTIONING_ENABLED; return new PlaybackStateCompat.Builder().setState(state, getCurrentPosition(), getPlaybackSpeed()) .setActions(allActions).setBufferedPosition(getBufferedPosition()).build(); }// w w w . j a v a2 s . c om }