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. The format is unspecified
but RFC 3339 is recommended. |
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}.
The artwork should be relatively small and may be scaled down by the
system if it is too large. For higher resolution artwork
{@link #METADATA_KEY_ART_URI} should be used instead. |
public static final String | METADATA_KEY_ART_URIThe artwork for the media as a Uri formatted String. The artwork can be
loaded using a combination of {@link ContentResolver#openInputStream} and
{@link BitmapFactory#decodeStream}.
For the best results, Uris should use the content:// style and support
{@link ContentResolver#EXTRA_SIZE} for retrieving scaled artwork through
{@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
public static final String | METADATA_KEY_ALBUM_ARTThe artwork for the album of the media's original source as a
{@link Bitmap}.
The artwork should be relatively small and may be scaled down by the
system if it is too large. For higher resolution artwork
{@link #METADATA_KEY_ALBUM_ART_URI} should be used instead. |
public static final String | METADATA_KEY_ALBUM_ART_URIThe artwork for the album of the media's original source as a Uri
formatted String. The artwork can be loaded using a combination of
{@link ContentResolver#openInputStream} and
{@link BitmapFactory#decodeStream}.
For the best results, Uris should use the content:// style and support
{@link ContentResolver#EXTRA_SIZE} for retrieving scaled artwork through
{@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
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}.
The icon should be relatively small and may be scaled down by the system
if it is too large. For higher resolution artwork
{@link #METADATA_KEY_DISPLAY_ICON_URI} should be used instead. |
public static final String | METADATA_KEY_DISPLAY_ICON_URIA Uri formatted String for an 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. The icon can be loaded using a combination of
{@link ContentResolver#openInputStream} and
{@link BitmapFactory#decodeStream}.
For the best results, Uris should use the content:// style and support
{@link ContentResolver#EXTRA_SIZE} for retrieving scaled artwork through
{@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}. |
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. It may be used with
{@link MediaController.TransportControls#playFromMediaId(String, Bundle)}
to initiate playback when provided by a {@link MediaBrowser} connected to
the same app. |
private static final String[] | PREFERRED_DESCRIPTION_ORDER |
private static final String[] | PREFERRED_BITMAP_ORDER |
private static final String[] | PREFERRED_URI_ORDER |
private static final int | METADATA_TYPE_INVALID |
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.util.ArrayMap | METADATA_KEYS_TYPE |
private static final android.util.SparseArray | EDITOR_KEY_MAPPING |
private final android.os.Bundle | mBundle |
private MediaDescription | 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 android.graphics.Bitmap | getBitmap(java.lang.String key)Returns 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 MediaDescription | 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;
}
}
MediaDescription.Builder bob = new MediaDescription.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 static java.lang.String | getKeyFromMetadataEditorKey(int editorKey)Helper for getting the String key used by {@link MediaMetadata} from the
integer key that {@link MediaMetadataEditor} uses.
return EDITOR_KEY_MAPPING.get(editorKey, null);
|
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 Rating | getRating(java.lang.String key)Returns a {@link Rating} for the given key or null if no rating exists
for the given key.
Rating 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 text value associated with the given key as a String, or null
if no mapping of the desired type exists for the given key or a null
value is explicitly associated with the key. This is equivalent to
calling {@link #getText getText().toString()} if the value is not null.
CharSequence text = getText(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()Returns the number of fields in this metadata.
return mBundle.size();
|
public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeBundle(mBundle);
|