Example usage for android.support.v4.media MediaMetadataCompat METADATA_KEY_ALBUM

List of usage examples for android.support.v4.media MediaMetadataCompat METADATA_KEY_ALBUM

Introduction

In this page you can find the example usage for android.support.v4.media MediaMetadataCompat METADATA_KEY_ALBUM.

Prototype

String METADATA_KEY_ALBUM

To view the source code for android.support.v4.media MediaMetadataCompat METADATA_KEY_ALBUM.

Click Source Link

Document

The album title for the media.

Usage

From source file:com.cyanogenmod.eleven.MusicPlaybackService.java

private void updateMediaSession(final String what) {
    int playState = mIsSupposedToBePlaying ? PlaybackStateCompat.STATE_PLAYING
            : PlaybackStateCompat.STATE_PAUSED;

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

    if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) {
        mSession.setPlaybackState(new PlaybackStateCompat.Builder().setActions(playBackStateActions)
                .setState(playState, position(), 1.0f).build());
    } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) {
        Bitmap albumArt = getAlbumArt(false).getBitmap();
        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) {
                config = Bitmap.Config.ARGB_8888;
            }//from www.  ja  v  a 2  s  .com
            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());

        mSession.setPlaybackState(new PlaybackStateCompat.Builder().setActions(playBackStateActions)
                .setState(playState, position(), 1.0f).build());
    }
}