Example usage for android.media.session PlaybackState ACTION_PLAY_FROM_MEDIA_ID

List of usage examples for android.media.session PlaybackState ACTION_PLAY_FROM_MEDIA_ID

Introduction

In this page you can find the example usage for android.media.session PlaybackState ACTION_PLAY_FROM_MEDIA_ID.

Prototype

long ACTION_PLAY_FROM_MEDIA_ID

To view the source code for android.media.session PlaybackState ACTION_PLAY_FROM_MEDIA_ID.

Click Source Link

Document

Indicates this session supports the play from media id command.

Usage

From source file:hkapps.playmxtv.Activities.PlaybackOverlayActivity.java

private long getAvailableActions() {
    long actions = PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID
            | PlaybackState.ACTION_PLAY_FROM_SEARCH;

    return actions;
}

From source file:de.kraenksoft.c3tv.ui.PlaybackOverlayFragment.java

private long getAvailableActions(int nextState) {
    long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID
            | PlaybackState.ACTION_PLAY_FROM_SEARCH | PlaybackState.ACTION_SKIP_TO_NEXT
            | PlaybackState.ACTION_SKIP_TO_PREVIOUS | PlaybackState.ACTION_PAUSE;

    if (nextState == PlaybackState.STATE_PLAYING) {
        actions |= PlaybackState.ACTION_PAUSE;
    }//ww w . j a v  a  2  s .  c  om

    return actions;
}

From source file:org.mythtv.android.presentation.view.fragment.TvPlaybackOverlayFragment.java

private long getAvailableActions(int nextState) {

    long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID
            | PlaybackState.ACTION_PLAY_FROM_SEARCH | PlaybackState.ACTION_SKIP_TO_NEXT
            | PlaybackState.ACTION_SKIP_TO_PREVIOUS | PlaybackState.ACTION_PAUSE;

    if (nextState == PlaybackState.STATE_PLAYING) {

        actions |= PlaybackState.ACTION_PAUSE;

    }/*from ww  w.  j av  a 2s.  c  o m*/

    return actions;
}

From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java

private long getAvailableActions(int nextState) {
    long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID
            | PlaybackState.ACTION_PLAY_FROM_SEARCH | PlaybackState.ACTION_SKIP_TO_NEXT
            | PlaybackState.ACTION_SKIP_TO_PREVIOUS | PlaybackState.ACTION_FAST_FORWARD
            | PlaybackState.ACTION_REWIND | PlaybackState.ACTION_PAUSE;

    if (nextState == PlaybackState.STATE_PLAYING) {
        actions |= PlaybackState.ACTION_PAUSE;
    }/*  w  w  w  .jav a2  s.  com*/

    return actions;
}

From source file:com.koma.music.service.MusicService.java

private void updateMediaSession(final String what) {
    LogUtils.i(TAG, "updateMediaSession what : " + what);
    int playState = mIsSupposedToBePlaying ? PlaybackState.STATE_PLAYING : PlaybackState.STATE_PAUSED;

    long playBackStateActions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_PAUSE
            | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID | PlaybackState.ACTION_PAUSE
            | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS
            | PlaybackState.ACTION_STOP;

    if (what.equals(MusicServiceConstants.PLAYSTATE_CHANGED)
            || what.equals(MusicServiceConstants.POSITION_CHANGED)) {
        mSession.setPlaybackState(new PlaybackState.Builder().setActions(playBackStateActions)
                .setActiveQueueItemId(getAudioId()).setState(playState, position(), 1.0f).build());
    } else if (what.equals(META_CHANGED) || what.equals(MusicServiceConstants.QUEUE_CHANGED)) {
        LogUtils.i(TAG, "sadsadsadsad thread id : " + Thread.currentThread().getId() + "name : "
                + Thread.currentThread().getName());
        /*if (albumArt != null) {
        // RemoteControlClient wants to recycle the bitmaps thrown at it, so we need
        // to make sure not to hand out our cache copy
        Bitmap.Config config = albumArt.getConfig();
        if (config == null) {/*from  w  w  w  .j  ava2s  . c om*/
            config = Bitmap.Config.ARGB_8888;
        }
        albumArt = albumArt.copy(config, false);
        }*/

        /*mSession.setMetadata(new MediaMetadataCompat.Builder()
            .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, getArtistName())
            .putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, getAlbumArtistName())
            .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, getAlbumName())
            .putString(MediaMetadataCompat.METADATA_KEY_TITLE, getTrackName())
            .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration())
            .putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getQueuePosition() + 1)
            .putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getQueue().length)
            .putString(MediaMetadataCompat.METADATA_KEY_GENRE, getGenreName())
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART,
                    mShowAlbumArtOnLockscreen ? albumArt : null)
            .build());*/

        if (what.equals(MusicServiceConstants.QUEUE_CHANGED)) {
            updateMediaSessionQueue();
        }

        mSession.setPlaybackState(new PlaybackState.Builder().setActions(playBackStateActions)
                .setActiveQueueItemId(getAudioId()).setState(playState, position(), 1.0f).build());
    }
    LogUtils.i(TAG, "updateMediaSession finished");
}