Fields Summary |
---|
private static final String | TAG |
public static final String | METADATA_KEY_TITLEThe title of the media. |
public static final String | METADATA_KEY_ARTISTThe artist of the media. |
public static final String | METADATA_KEY_DURATIONThe duration of the media in ms. A negative duration indicates that the
duration is unknown (or infinite). |
public static final String | METADATA_KEY_ALBUMThe album title for the media. |
public static final String | METADATA_KEY_AUTHORThe author of the media. |
public static final String | METADATA_KEY_WRITERThe writer of the media. |
public static final String | METADATA_KEY_COMPOSERThe composer of the media. |
public static final String | METADATA_KEY_COMPILATIONThe compilation status of the media. |
public static final String | METADATA_KEY_DATEThe date the media was created or published as TODO determine format. |
public static final String | METADATA_KEY_YEARThe year the media was created or published as a long. |
public static final String | METADATA_KEY_GENREThe genre of the media. |
public static final String | METADATA_KEY_TRACK_NUMBERThe track number for the media. |
public static final String | METADATA_KEY_NUM_TRACKSThe number of tracks in the media's original source. |
public static final String | METADATA_KEY_DISC_NUMBERThe disc number for the media's original source. |
public static final String | METADATA_KEY_ALBUM_ARTISTThe artist for the album of the media's original source. |
public static final String | METADATA_KEY_ARTThe artwork for the media as a {@link Bitmap}. |
public static final String | METADATA_KEY_ART_URIThe artwork for the media as a Uri style String. |
public static final String | METADATA_KEY_ALBUM_ARTThe artwork for the album of the media's original source as a
{@link Bitmap}. |
public static final String | METADATA_KEY_ALBUM_ART_URIThe artwork for the album of the media's original source as a Uri style
String. |
public static final String | METADATA_KEY_USER_RATINGThe user's rating for the media. |
public static final String | METADATA_KEY_RATINGThe overall rating for the media. |
public static final String | METADATA_KEY_DISPLAY_TITLEA title that is suitable for display to the user. This will generally be
the same as {@link #METADATA_KEY_TITLE} but may differ for some formats.
When displaying media described by this metadata this should be preferred
if present. |
public static final String | METADATA_KEY_DISPLAY_SUBTITLEA subtitle that is suitable for display to the user. When displaying a
second line for media described by this metadata this should be preferred
to other fields if present. |
public static final String | METADATA_KEY_DISPLAY_DESCRIPTIONA description that is suitable for display to the user. When displaying
more information for media described by this metadata this should be
preferred to other fields if present. |
public static final String | METADATA_KEY_DISPLAY_ICONAn icon or thumbnail that is suitable for display to the user. When
displaying an icon for media described by this metadata this should be
preferred to other fields if present. This must be a {@link Bitmap}. |
public static final String | METADATA_KEY_DISPLAY_ICON_URIAn icon or thumbnail that is suitable for display to the user. When
displaying more information for media described by this metadata the
display description should be preferred to other fields when present.
This must be a Uri style String. |
public static final String | METADATA_KEY_MEDIA_IDA String key for identifying the content. This value is specific to the
service providing the content. If used, this should be a persistent
unique key for the underlying content. |
private static final int | METADATA_TYPE_LONG |
private static final int | METADATA_TYPE_TEXT |
private static final int | METADATA_TYPE_BITMAP |
private static final int | METADATA_TYPE_RATING |
private static final android.support.v4.util.ArrayMap | METADATA_KEYS_TYPE |
private static final String[] | PREFERRED_DESCRIPTION_ORDER |
private static final String[] | PREFERRED_BITMAP_ORDER |
private static final String[] | PREFERRED_URI_ORDER |
private final android.os.Bundle | mBundle |
private Object | mMetadataObj |
private MediaDescriptionCompat | mDescription |
public static final Parcelable.Creator | CREATOR |
Methods Summary |
---|
public boolean | containsKey(java.lang.String key)Returns true if the given key is contained in the metadata
return mBundle.containsKey(key);
|
public int | describeContents()
return 0;
|
public static android.support.v4.media.MediaMetadataCompat | fromMediaMetadata(java.lang.Object metadataObj)Creates an instance from a framework {@link android.media.MediaMetadata}
object.
This method is only supported on
{@link android.os.Build.VERSION_CODES#LOLLIPOP} and later.
if (metadataObj == null || Build.VERSION.SDK_INT < 21) {
return null;
}
Builder builder = new Builder();
for (String key : MediaMetadataCompatApi21.keySet(metadataObj)) {
Integer type = METADATA_KEYS_TYPE.get(key);
if (type != null) {
switch (type) {
case METADATA_TYPE_BITMAP:
builder.putBitmap(key,
MediaMetadataCompatApi21.getBitmap(metadataObj, key));
break;
case METADATA_TYPE_LONG:
builder.putLong(key,
MediaMetadataCompatApi21.getLong(metadataObj, key));
break;
case METADATA_TYPE_RATING:
builder.putRating(key, RatingCompat.fromRating(
MediaMetadataCompatApi21.getRating(metadataObj, key)));
break;
case METADATA_TYPE_TEXT:
builder.putText(key,
MediaMetadataCompatApi21.getText(metadataObj, key));
break;
}
}
}
MediaMetadataCompat metadata = builder.build();
metadata.mMetadataObj = metadataObj;
return metadata;
|
public android.graphics.Bitmap | getBitmap(java.lang.String key)Return a {@link Bitmap} for the given key or null if no bitmap exists for
the given key.
Bitmap bmp = null;
try {
bmp = mBundle.getParcelable(key);
} catch (Exception e) {
// ignore, value was not a bitmap
Log.w(TAG, "Failed to retrieve a key as Bitmap.", e);
}
return bmp;
|
public android.os.Bundle | getBundle()Gets the bundle backing the metadata object. This is available to support
backwards compatibility. Apps should not modify the bundle directly.
return mBundle;
|
public MediaDescriptionCompat | getDescription()Returns a simple description of this metadata for display purposes.
if (mDescription != null) {
return mDescription;
}
String mediaId = getString(METADATA_KEY_MEDIA_ID);
CharSequence[] text = new CharSequence[3];
Bitmap icon = null;
Uri iconUri = null;
// First handle the case where display data is set already
CharSequence displayText = getText(METADATA_KEY_DISPLAY_TITLE);
if (!TextUtils.isEmpty(displayText)) {
// If they have a display title use only display data, otherwise use
// our best bets
text[0] = displayText;
text[1] = getText(METADATA_KEY_DISPLAY_SUBTITLE);
text[2] = getText(METADATA_KEY_DISPLAY_DESCRIPTION);
} else {
// Use whatever fields we can
int textIndex = 0;
int keyIndex = 0;
while (textIndex < text.length && keyIndex < PREFERRED_DESCRIPTION_ORDER.length) {
CharSequence next = getText(PREFERRED_DESCRIPTION_ORDER[keyIndex++]);
if (!TextUtils.isEmpty(next)) {
// Fill in the next empty bit of text
text[textIndex++] = next;
}
}
}
// Get the best art bitmap we can find
for (int i = 0; i < PREFERRED_BITMAP_ORDER.length; i++) {
Bitmap next = getBitmap(PREFERRED_BITMAP_ORDER[i]);
if (next != null) {
icon = next;
break;
}
}
// Get the best Uri we can find
for (int i = 0; i < PREFERRED_URI_ORDER.length; i++) {
String next = getString(PREFERRED_URI_ORDER[i]);
if (!TextUtils.isEmpty(next)) {
iconUri = Uri.parse(next);
break;
}
}
MediaDescriptionCompat.Builder bob = new MediaDescriptionCompat.Builder();
bob.setMediaId(mediaId);
bob.setTitle(text[0]);
bob.setSubtitle(text[1]);
bob.setDescription(text[2]);
bob.setIconBitmap(icon);
bob.setIconUri(iconUri);
mDescription = bob.build();
return mDescription;
|
public long | getLong(java.lang.String key)Returns the value associated with the given key, or 0L if no long exists
for the given key.
return mBundle.getLong(key, 0);
|
public java.lang.Object | getMediaMetadata()Gets the underlying framework {@link android.media.MediaMetadata} object.
This method is only supported on
{@link android.os.Build.VERSION_CODES#LOLLIPOP} and later.
if (mMetadataObj != null || Build.VERSION.SDK_INT < 21) {
return mMetadataObj;
}
Object builderObj = MediaMetadataCompatApi21.Builder.newInstance();
for (String key : keySet()) {
Integer type = METADATA_KEYS_TYPE.get(key);
if (type != null) {
switch (type) {
case METADATA_TYPE_BITMAP:
MediaMetadataCompatApi21.Builder.putBitmap(builderObj, key,
getBitmap(key));
break;
case METADATA_TYPE_LONG:
MediaMetadataCompatApi21.Builder.putLong(builderObj, key,
getLong(key));
break;
case METADATA_TYPE_RATING:
MediaMetadataCompatApi21.Builder.putRating(builderObj, key,
getRating(key).getRating());
break;
case METADATA_TYPE_TEXT:
MediaMetadataCompatApi21.Builder.putText(builderObj, key,
getText(key));
break;
}
}
}
mMetadataObj = MediaMetadataCompatApi21.Builder.build(builderObj);
return mMetadataObj;
|
public RatingCompat | getRating(java.lang.String key)Return a {@link RatingCompat} for the given key or null if no rating exists for
the given key.
RatingCompat rating = null;
try {
rating = mBundle.getParcelable(key);
} catch (Exception e) {
// ignore, value was not a bitmap
Log.w(TAG, "Failed to retrieve a key as Rating.", e);
}
return rating;
|
public java.lang.String | getString(java.lang.String key)Returns the value associated with the given key, or null if no mapping of
the desired type exists for the given key or a null value is explicitly
associated with the key.
CharSequence text = mBundle.getCharSequence(key);
if (text != null) {
return text.toString();
}
return null;
|
public java.lang.CharSequence | getText(java.lang.String key)Returns the value associated with the given key, or null if no mapping of
the desired type exists for the given key or a null value is explicitly
associated with the key.
return mBundle.getCharSequence(key);
|
public java.util.Set | keySet()Returns a Set containing the Strings used as keys in this metadata.
return mBundle.keySet();
|
public int | size()Get the number of fields in this metadata.
return mBundle.size();
|
public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeBundle(mBundle);
|