Example usage for android.support.v4.media.session PlaybackStateCompat ACTION_FAST_FORWARD

List of usage examples for android.support.v4.media.session PlaybackStateCompat ACTION_FAST_FORWARD

Introduction

In this page you can find the example usage for android.support.v4.media.session PlaybackStateCompat ACTION_FAST_FORWARD.

Prototype

long ACTION_FAST_FORWARD

To view the source code for android.support.v4.media.session PlaybackStateCompat ACTION_FAST_FORWARD.

Click Source Link

Document

Indicates this session supports the fast forward command.

Usage

From source file:org.runbuddy.tomahawk.services.PlaybackService.java

private void updateMediaPlayState() {
    if (mMediaSession == null) {
        Log.e(TAG, "updateMediaPlayState failed - mMediaSession == null!");
        return;// w  ww.j  av  a 2 s  . co  m
    }
    long actions = 0L;
    if (mPlaybackManager.getCurrentQuery() != null) {
        actions |= PlaybackStateCompat.ACTION_SET_RATING;
    }
    if (mPlayState == PlaybackStateCompat.STATE_PLAYING) {
        actions |= PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SEEK_TO
                | PlaybackStateCompat.ACTION_FAST_FORWARD | PlaybackStateCompat.ACTION_REWIND;
    } else {
        actions |= PlaybackStateCompat.ACTION_PLAY;
    }
    if (mPlaybackManager.hasNextEntry()) {
        actions |= PlaybackStateCompat.ACTION_SKIP_TO_NEXT;
    }
    if (mPlaybackManager.hasPreviousEntry()) {
        actions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS;
    }
    Log.d(TAG, "updateMediaPlayState()");
    Bundle extras = new Bundle();
    extras.putInt(EXTRAS_KEY_REPEAT_MODE, mPlaybackManager.getRepeatMode());
    extras.putInt(EXTRAS_KEY_SHUFFLE_MODE, mPlaybackManager.getShuffleMode());
    int playState = mIsPreparing ? PlaybackStateCompat.STATE_BUFFERING : mPlayState;
    PlaybackStateCompat playbackStateCompat = new PlaybackStateCompat.Builder().setActions(actions)
            .setState(playState, getPlaybackPosition(), 1f, SystemClock.elapsedRealtime()).setExtras(extras)
            .build();
    mMediaSession.setPlaybackState(playbackStateCompat);
}