mSession.setPlaybackState(new PlaybackState.Builder() .setState(playState, position(), 1.0f) .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE | .build()); mSession.setPlaybackState(new PlaybackState.Builder() .setState(playState, position(), 1.0f) .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE |
public static void setPlaybackState(Object sessionObj, Object stateObj) { ((MediaSession)sessionObj).setPlaybackState((PlaybackState)stateObj); }
@Override public void closePlayer() { stopVideo(); PlaybackState.Builder stateBuilder = new PlaybackState.Builder(); stateBuilder.setState(PlaybackState.STATE_PAUSED, 12, 1); mMediaSession.setPlaybackState(stateBuilder.build()); mMediaSession.setActive(false); Log.i(TAG, "closePlayer : " + mMediaSession.isActive()); }
private void updatePlaybackState(int position) { PlaybackState.Builder stateBuilder = new PlaybackState.Builder() .setActions(getAvailableActions()); int state = PlaybackState.STATE_PLAYING; if (mPlaybackState == LeanbackPlaybackState.PAUSED) { state = PlaybackState.STATE_PAUSED; } stateBuilder.setState(state, position, 1.0f); mSession.setPlaybackState(stateBuilder.build()); }
public static void updateMediaSession(boolean updateMetadata, MediaMetadata.Builder mediaBuilder, final MediaSession mediaSession, final int playbackState, final long position, final float speed) { if (mediaSession.isActive()) { if (updateMetadata) { mediaSession.setMetadata(mediaBuilder.build()); } PlaybackState.Builder stateBuilder = new PlaybackState.Builder(); stateBuilder.setState(playbackState, position, speed); mediaSession.setPlaybackState(stateBuilder.build()); } } }
/** * Update the current media player state, optionally showing an error message. * * @param error if not null, error message to present to the user. */ private void updatePlaybackState(String error) { long position = PlaybackState.PLAYBACK_POSITION_UNKNOWN; int state = PlaybackState.STATE_PAUSED; if(PlaybackService.hasInstance()) { if (PlaybackService.get(this).isPlaying()) { state = PlaybackState.STATE_PLAYING; } position = PlaybackService.get(this).getPosition(); } PlaybackState.Builder stateBuilder = new PlaybackState.Builder() .setActions(getAvailableActions()); setCustomAction(stateBuilder); // If there is an error message, send it to the playback state: if (error != null) { // Error states are really only supposed to be used for errors that cause playback to // stop unexpectedly and persist until the user takes action to fix it. stateBuilder.setErrorMessage(error); state = PlaybackState.STATE_ERROR; } stateBuilder.setState(state, position, 1.0f, SystemClock.elapsedRealtime()); mSession.setPlaybackState(stateBuilder.build()); } // 'DriveSafe' icons need to meet contrast requirement, and as such are usually
session.setPlaybackState(new PlaybackState.Builder() .setState(playbackState, service.getPosition(), 1.0f) .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_STOP | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE |