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

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

Introduction

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

Prototype

String METADATA_KEY_DISPLAY_ICON

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

Click Source Link

Document

An icon or thumbnail that is suitable for display to the user.

Usage

From source file:com.scooter1556.sms.lib.android.utils.MediaUtils.java

public static MediaMetadataCompat getMediaMetadata(MediaElement mediaElement, Bitmap artwork) {
    if (mediaElement == null) {
        return null;
    }/* ww w  .jav  a  2 s.  c o m*/

    // Update session metadata
    MediaMetadataCompat.Builder metadata = new MediaMetadataCompat.Builder();
    metadata.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, mediaElement.getID().toString());

    if (mediaElement.getArtist() != null) {
        metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, mediaElement.getArtist());
        metadata.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, mediaElement.getArtist());
    }

    if (mediaElement.getAlbum() != null) {
        metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, mediaElement.getAlbum());
        metadata.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, mediaElement.getAlbum());
    }

    if (mediaElement.getTitle() != null) {
        metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, mediaElement.getTitle());
        metadata.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, mediaElement.getTitle());
    }

    if (mediaElement.getDuration() != null) {
        metadata.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, mediaElement.getDuration() * 1000);
    }

    if (mediaElement.getYear() != null) {
        metadata.putLong(MediaMetadataCompat.METADATA_KEY_YEAR, mediaElement.getYear());
    }

    if (mediaElement.getGenre() != null) {
        metadata.putString(MediaMetadataCompat.METADATA_KEY_GENRE, mediaElement.getGenre());
    }

    if (mediaElement.getTrackNumber() != null) {
        metadata.putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, mediaElement.getTrackNumber());
    }

    if (mediaElement.getDiscNumber() != null) {
        metadata.putLong(MediaMetadataCompat.METADATA_KEY_DISC_NUMBER, mediaElement.getDiscNumber());
    }

    if (mediaElement.getAlbumArtist() != null) {
        metadata.putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, mediaElement.getAlbumArtist());
    }

    if (artwork != null) {
        metadata.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, artwork);
        metadata.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, artwork);
        metadata.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, artwork);
    }

    return metadata.build();
}

From source file:nuclei.media.MediaMetadata.java

public void setDisplayIcon(Bitmap icon) {
    mMetadata = new MediaMetadataCompat.Builder(mMetadata)
            .putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, icon).build();
    onMetadataChanged();//from ww w.  j  a v  a2  s. c om
}

From source file:com.example.android.supportv7.media.Player.java

protected void updateMetadata() {
    if (mMediaSession == null) {
        return;//from   w w  w.  ja  va 2  s.co m
    }
    MediaMetadataCompat.Builder bob = new MediaMetadataCompat.Builder();
    bob.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE, getDescription());
    bob.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE, "Subtitle of the thing");
    bob.putString(MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION, "Description of the thing");
    bob.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, getSnapshot());
    mMediaSession.setMetadata(bob.build());
}

From source file:com.radiofarda.istgah.model.MusicProvider.java

public synchronized void updateMusicArt(String musicId, Bitmap albumArt, Bitmap icon) {
    MediaMetadataCompat metadata = getMusic(musicId);
    metadata = new MediaMetadataCompat.Builder(metadata)

            // set high resolution bitmap in METADATA_KEY_ALBUM_ART. This is used, for
            // radiofarda, on the lockscreen background when the media session is active.
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt)

            // set small version of the album art in the DISPLAY_ICON. This is used on
            // the MediaDescription and thus it should be small to be serialized if
            // necessary
            .putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, icon)

            .build();/*from ww w .ja  v  a2s .  c  o  m*/

    MutableMediaMetadata mutableMetadata = mMusicListById.get(musicId);
    if (mutableMetadata == null) {
        throw new IllegalStateException("Unexpected error: Inconsistent data structures in " + "MusicProvider");
    }

    mutableMetadata.metadata = metadata;
}

From source file:com.phearom.um.model.MusicProvider.java

public void updateMusicArt(String musicId, Bitmap albumArt, Bitmap icon) {
    MediaMetadataCompat metadata = getMusic(musicId);
    metadata = new MediaMetadataCompat.Builder(metadata)
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt)
            .putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, icon).build();

    MutableMediaMetadata mutableMetadata = mMusicListById.get(musicId);
    if (mutableMetadata == null) {
        throw new IllegalStateException("Unexpected error: Inconsistent data structures in " + "MusicProvider");
    }//  ww  w  . j  a  va  2s  .  c o m

    mutableMetadata.metadata = metadata;
}

From source file:com.classiqo.nativeandroid_32bitz.model.MusicProvider.java

public synchronized void updateMusicArt(String musicId, Bitmap albumArt, Bitmap icon) {
    MediaMetadataCompat metadata = getMusic(musicId);
    metadata = new MediaMetadataCompat.Builder(metadata)
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt)
            .putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, icon).build();

    MutableMediaMetadata mutableMetadata = mMusicListById.get(musicId);

    if (mutableMetadata == null) {
        throw new IllegalStateException("Unexpected error: Inconsistent data structures in " + "MusicProvider");
    }/*  www.j  av  a2  s.  c om*/

    mutableMetadata.metadata = metadata;
}

From source file:com.devbrackets.android.exomedia.EMLockScreen.java

/**
 * Sets the volatile information for the lock screen controls.  This information is expected to
 * change frequently./*from  ww  w  . ja va2s .  c  o m*/
 *
 * @param title The title to display for the notification (e.g. A song name)
 * @param album The name of the album the media is found in
 * @param artist The name of the artist for the media item
 * @param notificationMediaState The current media state for the expanded (big) notification
 */
@SuppressWarnings("ResourceType") //getPlaybackOptions() and getPlaybackState() return the correctly annotated items
public void updateLockScreenInformation(String title, String album, String artist, Bitmap mediaArtwork,
        EMNotification.NotificationMediaState notificationMediaState) {
    //Updates the current media MetaData
    MediaMetadataCompat.Builder metaDataBuilder = new MediaMetadataCompat.Builder();
    metaDataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, appIconBitmap);
    metaDataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title);
    metaDataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, album);
    metaDataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist);

    if (mediaArtwork != null) {
        metaDataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, mediaArtwork);
    }

    mediaSession.setMetadata(metaDataBuilder.build());

    //Updates the available playback controls
    PlaybackStateCompat.Builder playbackStateBuilder = new PlaybackStateCompat.Builder();
    playbackStateBuilder.setActions(getPlaybackOptions(notificationMediaState));
    playbackStateBuilder.setState(getPlaybackState(notificationMediaState.isPlaying()),
            PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f);

    mediaSession.setPlaybackState(playbackStateBuilder.build());
    Log.d(TAG, "update, controller is null ? " + (mediaSession.getController() == null ? "true" : "false"));

    if (showLockScreen && !mediaSession.isActive()) {
        mediaSession.setActive(true);
    }
}

From source file:com.devbrackets.android.playlistcore.helper.MediaControlsHelper.java

/**
 * Sets the volatile information for the remote views and controls.  This information is expected to
 * change frequently./*from w  ww . ja va  2  s .  c  o  m*/
 *
 * @param title The title to display for the notification (e.g. A song name)
 * @param album The name of the album the media is found in
 * @param artist The name of the artist for the media item
 * @param notificationMediaState The current media state for the expanded (big) notification
 */
@SuppressWarnings("ResourceType") //getPlaybackOptions() and getPlaybackState() return the correctly annotated items
public void update(@Nullable String title, @Nullable String album, @Nullable String artist,
        @Nullable Bitmap mediaArtwork,
        @NonNull NotificationHelper.NotificationMediaState notificationMediaState) {
    //Updates the current media MetaData
    MediaMetadataCompat.Builder metaDataBuilder = new MediaMetadataCompat.Builder();
    metaDataBuilder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title);
    metaDataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, album);
    metaDataBuilder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist);

    if (appIconBitmap != null) {
        metaDataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, appIconBitmap);
    }

    if (mediaArtwork != null) {
        metaDataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, mediaArtwork);
    }

    if (mediaSession != null) {
        mediaSession.setMetadata(metaDataBuilder.build());
    }

    //Updates the available playback controls
    PlaybackStateCompat.Builder playbackStateBuilder = new PlaybackStateCompat.Builder();
    playbackStateBuilder.setActions(getPlaybackOptions(notificationMediaState));
    playbackStateBuilder.setState(getPlaybackState(notificationMediaState.isPlaying()),
            PlaybackStateCompat.PLAYBACK_POSITION_UNKNOWN, 1.0f);

    mediaSession.setPlaybackState(playbackStateBuilder.build());
    Log.d(TAG, "update, controller is null ? " + (mediaSession.getController() == null ? "true" : "false"));

    if (enabled && !mediaSession.isActive()) {
        mediaSession.setActive(true);
    }
}

From source file:com.mts2792.music.uamp.model.MusicProvider.java

public synchronized void updateMusicArt(String musicId, Bitmap albumArt, Bitmap icon) {
    MediaMetadataCompat metadata = getMusic(musicId);
    metadata = new MediaMetadataCompat.Builder(metadata)

            // set high resolution bitmap in METADATA_KEY_ALBUM_ART. This is used, for
            // mts2792, on the lockscreen background when the media session is active.
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt)

            // set small version of the album art in the DISPLAY_ICON. This is used on
            // the MediaDescription and thus it should be small to be serialized if
            // necessary
            .putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, icon)

            .build();/*w  ww  .jav a2  s.  c o m*/

    MutableMediaMetadata mutableMetadata = mMusicListById.get(musicId);
    if (mutableMetadata == null) {
        throw new IllegalStateException("Unexpected error: Inconsistent data structures in " + "MusicProvider");
    }

    mutableMetadata.metadata = metadata;
}

From source file:com.example.lzhang.stockchartt.media.model.MusicProvider.java

public synchronized void updateMusicArt(String musicId, Bitmap albumArt, Bitmap icon) {
    MediaMetadataCompat metadata = getMusic(musicId);
    metadata = new MediaMetadataCompat.Builder(metadata)

            // set high resolution bitmap in METADATA_KEY_ALBUM_ART. This is used, for
            // example, on the lockscreen background when the media session is active.
            .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt)

            // set small version of the album art in the DISPLAY_ICON. This is used on
            // the MediaDescription and thus it should be small to be serialized if
            // necessary
            .putBitmap(MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON, icon)

            .build();//from   w w w .  ja  v  a2 s  . c o  m

    MutableMediaMetadata mutableMetadata = mMusicListById.get(musicId);
    if (mutableMetadata == null) {
        throw new IllegalStateException(
                "Unexpected error: Inconsistent data structures in " + "MusicProviderV2");
    }

    mutableMetadata.metadata = metadata;
}