Java Code Examples for android.support.v4.media.MediaMetadataCompat#METADATA_KEY_ALBUM

The following examples show how to use android.support.v4.media.MediaMetadataCompat#METADATA_KEY_ALBUM . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MusicLibrary.java    From android-MediaBrowserService with Apache License 2.0 8 votes vote down vote up
public static MediaMetadataCompat getMetadata(Context context, String mediaId) {
    MediaMetadataCompat metadataWithoutBitmap = music.get(mediaId);
    Bitmap albumArt = getAlbumBitmap(context, mediaId);

    // Since MediaMetadataCompat is immutable, we need to create a copy to set the album art.
    // We don't set it initially on all items so that they don't take unnecessary memory.
    MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
    for (String key :
            new String[]{
                    MediaMetadataCompat.METADATA_KEY_MEDIA_ID,
                    MediaMetadataCompat.METADATA_KEY_ALBUM,
                    MediaMetadataCompat.METADATA_KEY_ARTIST,
                    MediaMetadataCompat.METADATA_KEY_GENRE,
                    MediaMetadataCompat.METADATA_KEY_TITLE
            }) {
        builder.putString(key, metadataWithoutBitmap.getString(key));
    }
    builder.putLong(
            MediaMetadataCompat.METADATA_KEY_DURATION,
            metadataWithoutBitmap.getLong(MediaMetadataCompat.METADATA_KEY_DURATION));
    builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, albumArt);
    return builder.build();
}
 
Example 2
Source File: RemoteControlCompat.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** @return {@link android.support.v4.media.MediaMetadataCompat} log info (what keys it contains). */
public static String getMediaMetadataLog(MediaMetadataCompat metadata) {
    if (null == metadata) return "";
    final String[] METADATA_KEYS = new String[] {
        MediaMetadataCompat.METADATA_KEY_ALBUM,
        MediaMetadataCompat.METADATA_KEY_ALBUM_ART,
        MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST,
        MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI,
        MediaMetadataCompat.METADATA_KEY_ART,
        MediaMetadataCompat.METADATA_KEY_ARTIST,
        MediaMetadataCompat.METADATA_KEY_ART_URI,
        MediaMetadataCompat.METADATA_KEY_AUTHOR,
        MediaMetadataCompat.METADATA_KEY_COMPILATION,
        MediaMetadataCompat.METADATA_KEY_COMPOSER,
        MediaMetadataCompat.METADATA_KEY_DATE,
        MediaMetadataCompat.METADATA_KEY_DISC_NUMBER,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE,
        MediaMetadataCompat.METADATA_KEY_DURATION,
        MediaMetadataCompat.METADATA_KEY_GENRE,
        MediaMetadataCompat.METADATA_KEY_NUM_TRACKS,
        MediaMetadataCompat.METADATA_KEY_RATING,
        MediaMetadataCompat.METADATA_KEY_TITLE,
        MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER,
        MediaMetadataCompat.METADATA_KEY_USER_RATING,
        MediaMetadataCompat.METADATA_KEY_WRITER,
        MediaMetadataCompat.METADATA_KEY_YEAR };
    StringBuffer builder = new StringBuffer("{");
    for (String key : METADATA_KEYS)
        builder.append(key).append('=').append(
                (metadata.containsKey(key)) ? metadata.getText(key) : false).append(',');
    builder.append('}');
    return builder.toString();
}
 
Example 3
Source File: RemoteControlCompat.java    From Noyze with Apache License 2.0 5 votes vote down vote up
/** @return {@link android.support.v4.media.MediaMetadataCompat} log info (what keys it contains). */
public static String getMediaMetadataLog(MediaMetadataCompat metadata) {
    if (null == metadata) return "";
    final String[] METADATA_KEYS = new String[] {
        MediaMetadataCompat.METADATA_KEY_ALBUM,
        MediaMetadataCompat.METADATA_KEY_ALBUM_ART,
        MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST,
        MediaMetadataCompat.METADATA_KEY_ALBUM_ART_URI,
        MediaMetadataCompat.METADATA_KEY_ART,
        MediaMetadataCompat.METADATA_KEY_ARTIST,
        MediaMetadataCompat.METADATA_KEY_ART_URI,
        MediaMetadataCompat.METADATA_KEY_AUTHOR,
        MediaMetadataCompat.METADATA_KEY_COMPILATION,
        MediaMetadataCompat.METADATA_KEY_COMPOSER,
        MediaMetadataCompat.METADATA_KEY_DATE,
        MediaMetadataCompat.METADATA_KEY_DISC_NUMBER,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_DESCRIPTION,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_ICON_URI,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_SUBTITLE,
        MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE,
        MediaMetadataCompat.METADATA_KEY_DURATION,
        MediaMetadataCompat.METADATA_KEY_GENRE,
        MediaMetadataCompat.METADATA_KEY_NUM_TRACKS,
        MediaMetadataCompat.METADATA_KEY_RATING,
        MediaMetadataCompat.METADATA_KEY_TITLE,
        MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER,
        MediaMetadataCompat.METADATA_KEY_USER_RATING,
        MediaMetadataCompat.METADATA_KEY_WRITER,
        MediaMetadataCompat.METADATA_KEY_YEAR };
    StringBuffer builder = new StringBuffer("{");
    for (String key : METADATA_KEYS)
        builder.append(key).append('=').append(
                (metadata.containsKey(key)) ? metadata.getText(key) : false).append(',');
    builder.append('}');
    return builder.toString();
}