List of usage examples for android.support.v4.media.session PlaybackStateCompat STATE_FAST_FORWARDING
int STATE_FAST_FORWARDING
To view the source code for android.support.v4.media.session PlaybackStateCompat STATE_FAST_FORWARDING.
Click Source Link
From source file:com.achep.acdisplay.services.media.MediaController2KitKat.java
@NonNull static SparseIntArray generatePlaybackCompatSparse() { SparseIntArray sia = new SparseIntArray(); sia.put(RemoteControlClient.PLAYSTATE_BUFFERING, PlaybackStateCompat.STATE_BUFFERING); sia.put(RemoteControlClient.PLAYSTATE_PLAYING, PlaybackStateCompat.STATE_PLAYING); sia.put(RemoteControlClient.PLAYSTATE_PAUSED, PlaybackStateCompat.STATE_PAUSED); sia.put(RemoteControlClient.PLAYSTATE_ERROR, PlaybackStateCompat.STATE_ERROR); sia.put(RemoteControlClient.PLAYSTATE_REWINDING, PlaybackStateCompat.STATE_REWINDING); sia.put(RemoteControlClient.PLAYSTATE_FAST_FORWARDING, PlaybackStateCompat.STATE_FAST_FORWARDING); sia.put(RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_NEXT); sia.put(RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS); return sia;/* w w w . j a va 2 s .c o m*/ }
From source file:com.bullmobi.message.services.media.MediaController2KitKat.java
/** * {@inheritDoc}//www . j a v a 2 s .c o m */ protected MediaController2KitKat(@NonNull Activity activity) { super(activity); SparseIntArray cachedStateSparse = sStateSparse.get(); if (cachedStateSparse == null) { mStateSparse = new SparseIntArray(); mStateSparse.put(RemoteControlClient.PLAYSTATE_BUFFERING, PlaybackStateCompat.STATE_BUFFERING); mStateSparse.put(RemoteControlClient.PLAYSTATE_PLAYING, PlaybackStateCompat.STATE_PLAYING); mStateSparse.put(RemoteControlClient.PLAYSTATE_PAUSED, PlaybackStateCompat.STATE_PAUSED); mStateSparse.put(RemoteControlClient.PLAYSTATE_ERROR, PlaybackStateCompat.STATE_ERROR); mStateSparse.put(RemoteControlClient.PLAYSTATE_REWINDING, PlaybackStateCompat.STATE_REWINDING); mStateSparse.put(RemoteControlClient.PLAYSTATE_FAST_FORWARDING, PlaybackStateCompat.STATE_FAST_FORWARDING); mStateSparse.put(RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_NEXT); mStateSparse.put(RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS, PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS); // Cache sparse array sStateSparse = new WeakReference<>(mStateSparse); } else { mStateSparse = cachedStateSparse; } }
From source file:nuclei.media.MediaPlayerController.java
@Override public int getCurrentPosition() { if (isEquals()) { PlaybackStateCompat state = mMediaControls.getPlaybackState(); if (state != null) { // KJB: NOTE: Pulled from media compat library // For some reason, it seems, that only API 21 doesn't do something equivalent // of this. weird. // Just to be safe, since this is important, doing it here. // It's a little redundant... but, I don't see how this would hurt anything // if it were executed twice (so long as getLastPositionUpdateTime is correct) // TODO: revisit this after support library 25.1.1 try { if ((state.getState() == PlaybackStateCompat.STATE_PLAYING || state.getState() == PlaybackStateCompat.STATE_FAST_FORWARDING || state.getState() == PlaybackStateCompat.STATE_REWINDING)) { final long updateTime = state.getLastPositionUpdateTime(); final long currentTime = SystemClock.elapsedRealtime(); if (updateTime > 0) { final float speed = state.getPlaybackSpeed(); final long duration = getDuration(); long position = (long) (speed * (currentTime - updateTime)) + state.getPosition(); if (duration >= 0 && position > duration) { position = duration; } else if (position < 0) { position = 0; }/* w ww . j ava2s . c o m*/ return (int) position; } } } catch (Exception err) { // because weird things happen sometimes :( LOG.e("Error calculating latest position", err); } return (int) state.getPosition(); } } return -1; }
From source file:android.support.v17.leanback.media.MediaControllerAdapter.java
@Override public boolean isPlaying() { if (mController.getPlaybackState() == null) { return false; }// ww w.j a v a 2s. c om return mController.getPlaybackState().getState() == PlaybackStateCompat.STATE_PLAYING || mController.getPlaybackState().getState() == PlaybackStateCompat.STATE_FAST_FORWARDING || mController.getPlaybackState().getState() == PlaybackStateCompat.STATE_REWINDING; }
From source file:com.mylovemhz.simplay.MusicService.java
public void fastForward() { if (currentState == State.STARTED || currentState == State.PAUSED || currentState == State.PREPARED || currentState == State.COMPLETED) { if (mediaPlayer.getCurrentPosition() < mediaPlayer.getDuration() + TIME_FFWD_RWD) { mediaPlayer.seekTo(mediaPlayer.getCurrentPosition() + TIME_FFWD_RWD); updateSessionState(PlaybackStateCompat.STATE_FAST_FORWARDING); }/*www .j a va 2 s .c o m*/ } }
From source file:androidx.media.MediaUtils2.java
static int toPlayerState(int playbackStateCompatState) { switch (playbackStateCompatState) { case PlaybackStateCompat.STATE_ERROR: return MediaPlayerBase.PLAYER_STATE_ERROR; case PlaybackStateCompat.STATE_NONE: return MediaPlayerBase.PLAYER_STATE_IDLE; case PlaybackStateCompat.STATE_PAUSED: case PlaybackStateCompat.STATE_STOPPED: case PlaybackStateCompat.STATE_BUFFERING: // means paused for buffering. return MediaPlayerBase.PLAYER_STATE_PAUSED; case PlaybackStateCompat.STATE_FAST_FORWARDING: case PlaybackStateCompat.STATE_PLAYING: case PlaybackStateCompat.STATE_REWINDING: case PlaybackStateCompat.STATE_SKIPPING_TO_NEXT: case PlaybackStateCompat.STATE_SKIPPING_TO_PREVIOUS: case PlaybackStateCompat.STATE_SKIPPING_TO_QUEUE_ITEM: case PlaybackStateCompat.STATE_CONNECTING: // Note: there's no perfect match for this. return MediaPlayerBase.PLAYER_STATE_PLAYING; }// w w w .ja v a2 s . co m return MediaPlayerBase.PLAYER_STATE_ERROR; }
From source file:com.mylovemhz.simplay.MusicService.java
public void seekTo(int position) { if (currentState == State.STARTED || currentState == State.PAUSED || currentState == State.PREPARED || currentState == State.COMPLETED) { mediaPlayer.seekTo(position);/* w ww. jav a2 s .c o m*/ updateSessionState(PlaybackStateCompat.STATE_FAST_FORWARDING); } }
From source file:com.mylovemhz.simplay.MusicService.java
public boolean isPlaying() { int state = getPlaybackState().getState(); return state == PlaybackStateCompat.STATE_BUFFERING || state == PlaybackStateCompat.STATE_FAST_FORWARDING || state == PlaybackStateCompat.STATE_PLAYING || state == PlaybackStateCompat.STATE_REWINDING; }
From source file:com.example.android.leanback.MediaSessionService.java
private void fastForward() { // To support fast forward action, the mRewindSpeedFactors must be provided through // setFastForwardSpeedFactors() method; if (mFastForwardSpeedFactors == null) { if (DEBUG) { Log.d(TAG, "FastForwardSpeedFactors are not set"); }/*from w ww . j av a 2 s .co m*/ return; } // Toggle the flag to indicate fast forward status. mIsFastForwarding = true; // The first element in mFastForwardSpeedFactors is used to represent the normal speed. // Will always be incremented by 1 firstly before setting the speed. mFastForwardSpeedFactorIndex += 1; if (mFastForwardSpeedFactorIndex > mFastForwardSpeedFactors.length - 1) { mFastForwardSpeedFactorIndex = mFastForwardSpeedFactors.length - 1; } // In our customized fast forward operation, the media player will not be paused, // But the player's speed will be changed accordingly. mPlayer.setPlaybackParams( mPlayer.getPlaybackParams().setSpeed(mFastForwardSpeedFactors[mFastForwardSpeedFactorIndex])); // Update playback state, mIsFastForwarding will be reset to false inside of it. mMediaSession .setPlaybackState(createPlaybackStateBuilder(PlaybackStateCompat.STATE_FAST_FORWARDING).build()); }