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

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

Introduction

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

Prototype

public Bitmap getBitmap(@BitmapKey String key) 

Source Link

Document

Return a Bitmap for the given key or null if no bitmap exists for the given key.

Usage

From source file:org.opensilk.music.ui3.main.FooterScreenPresenter.java

void subscribeBroadcasts() {
    if (isSubscribed(broadcastSubscriptions)) {
        return;/*from w w  w . j  a v  a2s .  c o m*/
    }
    Subscription s = playbackController.subscribePlayStateChanges(new Action1<PlaybackStateCompat>() {
        @Override
        public void call(PlaybackStateCompat playbackState) {
            final int state = playbackState.getState();
            if (state == STATE_BUFFERING || state == STATE_CONNECTING) {
                setProgress(-1);
            } else {
                long position = playbackState.getPosition();
                long duration = playbackState.getBufferedPosition();
                if (position < 0 || duration <= 0) {
                    setProgress(1000);
                } else {
                    setProgress((int) (1000 * position / duration));
                }
                Timber.v("Position discrepancy = %d", lastPosition - position);
                lastPosition = position;
                lastDuration = duration;
                lastPosSynced = true;
                subscribeProgress(MainPresenter.isPlaying(playbackState));
            }

        }
    });
    Subscription s2 = playbackController.subscribeMetaChanges(new Action1<MediaMetadataCompat>() {
        @Override
        public void call(MediaMetadataCompat mediaMetadata) {
            setTrackName(mediaMetadata.getString(METADATA_KEY_TITLE));
            setArtistName(mediaMetadata.getString(METADATA_KEY_ARTIST));
            updateArtwork(mediaMetadata.getBitmap(METADATA_KEY_ALBUM_ART));
        }
    });

    broadcastSubscriptions = new CompositeSubscription(s, s2);
}