MediaMetadata
public
final
class
MediaMetadata
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.media.MediaMetadata |
Contains metadata about an item, such as the title, artist, etc.
Summary
Nested classes | |
---|---|
class |
MediaMetadata.Builder
Use to build MediaMetadata objects. |
Constants | |
---|---|
String |
METADATA_KEY_ALBUM
The album title for the media. |
String |
METADATA_KEY_ALBUM_ART
The artwork for the album of the media's original source as a
|
String |
METADATA_KEY_ALBUM_ARTIST
The artist for the album of the media's original source. |
String |
METADATA_KEY_ALBUM_ART_URI
The artwork for the album of the media's original source as a Uri formatted String. |
String |
METADATA_KEY_ART
The artwork for the media as a |
String |
METADATA_KEY_ARTIST
The artist of the media. |
String |
METADATA_KEY_ART_URI
The artwork for the media as a Uri formatted String. |
String |
METADATA_KEY_AUTHOR
The author of the media. |
String |
METADATA_KEY_BT_FOLDER_TYPE
The bluetooth folder type of the media specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5. |
String |
METADATA_KEY_COMPILATION
The compilation status of the media. |
String |
METADATA_KEY_COMPOSER
The composer of the media. |
String |
METADATA_KEY_DATE
The date the media was created or published. |
String |
METADATA_KEY_DISC_NUMBER
The disc number for the media's original source. |
String |
METADATA_KEY_DISPLAY_DESCRIPTION
A description that is suitable for display to the user. |
String |
METADATA_KEY_DISPLAY_ICON
An icon or thumbnail that is suitable for display to the user. |
String |
METADATA_KEY_DISPLAY_ICON_URI
A Uri formatted String for an icon or thumbnail that is suitable for display to the user. |
String |
METADATA_KEY_DISPLAY_SUBTITLE
A subtitle that is suitable for display to the user. |
String |
METADATA_KEY_DISPLAY_TITLE
A title that is suitable for display to the user. |
String |
METADATA_KEY_DURATION
The duration of the media in ms. |
String |
METADATA_KEY_GENRE
The genre of the media. |
String |
METADATA_KEY_MEDIA_ID
A String key for identifying the content. |
String |
METADATA_KEY_MEDIA_URI
A Uri formatted String representing the content. |
String |
METADATA_KEY_NUM_TRACKS
The number of tracks in the media's original source. |
String |
METADATA_KEY_RATING
The overall rating for the media. |
String |
METADATA_KEY_TITLE
The title of the media. |
String |
METADATA_KEY_TRACK_NUMBER
The track number for the media. |
String |
METADATA_KEY_USER_RATING
The user's rating for the media. |
String |
METADATA_KEY_WRITER
The writer of the media. |
String |
METADATA_KEY_YEAR
The year the media was created or published as a long. |
Inherited constants |
---|
Fields | |
---|---|
public
static
final
Creator<MediaMetadata> |
CREATOR
|
Public methods | |
---|---|
boolean
|
containsKey(String key)
Returns true if the given key is contained in the metadata |
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
boolean
|
equals(Object o)
Compares the contents of this object to another MediaMetadata object. |
Bitmap
|
getBitmap(String key)
Returns a |
int
|
getBitmapDimensionLimit()
Gets the width/height limit (in pixels) for the bitmaps when this metadata was created. |
MediaDescription
|
getDescription()
Returns a simple description of this metadata for display purposes. |
long
|
getLong(String key)
Returns the value associated with the given key, or 0L if no long exists for the given key. |
Rating
|
getRating(String key)
Returns a |
String
|
getString(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. |
CharSequence
|
getText(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. |
int
|
hashCode()
Returns a hash code value for the object. |
Set<String>
|
keySet()
Returns a Set containing the Strings used as keys in this metadata. |
int
|
size()
Returns the number of fields in this metadata. |
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel. |
Inherited methods | |
---|---|
Constants
METADATA_KEY_ALBUM
public static final String METADATA_KEY_ALBUM
The album title for the media.
Constant Value: "android.media.metadata.ALBUM"
METADATA_KEY_ALBUM_ART
public static final String METADATA_KEY_ALBUM_ART
The artwork for the album of the media's original source as a
Bitmap
.
The artwork should be relatively small and may be scaled down by the
system if it is too large. For higher resolution artwork
METADATA_KEY_ALBUM_ART_URI
should be used instead.
Constant Value: "android.media.metadata.ALBUM_ART"
METADATA_KEY_ALBUM_ARTIST
public static final String METADATA_KEY_ALBUM_ARTIST
The artist for the album of the media's original source.
Constant Value: "android.media.metadata.ALBUM_ARTIST"
METADATA_KEY_ALBUM_ART_URI
public static final String METADATA_KEY_ALBUM_ART_URI
The artwork for the album of the media's original source as a Uri
formatted String. The artwork can be loaded using a combination of
ContentResolver.openInputStream
and
BitmapFactory.decodeStream
.
For the best results, Uris should use the content:// style and support
ContentResolver.EXTRA_SIZE
for retrieving scaled artwork through
ContentResolver.openTypedAssetFileDescriptor(Uri, String, Bundle)
.
Constant Value: "android.media.metadata.ALBUM_ART_URI"
METADATA_KEY_ART
public static final String METADATA_KEY_ART
The artwork for the media as a Bitmap
.
The artwork should be relatively small and may be scaled down by the
system if it is too large. For higher resolution artwork
METADATA_KEY_ART_URI
should be used instead.
Constant Value: "android.media.metadata.ART"
METADATA_KEY_ARTIST
public static final String METADATA_KEY_ARTIST
The artist of the media.
Constant Value: "android.media.metadata.ARTIST"
METADATA_KEY_ART_URI
public static final String METADATA_KEY_ART_URI
The artwork for the media as a Uri formatted String. The artwork can be
loaded using a combination of ContentResolver.openInputStream
and
BitmapFactory.decodeStream
.
For the best results, Uris should use the content:// style and support
ContentResolver.EXTRA_SIZE
for retrieving scaled artwork through
ContentResolver.openTypedAssetFileDescriptor(Uri, String, Bundle)
.
Constant Value: "android.media.metadata.ART_URI"
METADATA_KEY_AUTHOR
public static final String METADATA_KEY_AUTHOR
The author of the media.
Constant Value: "android.media.metadata.AUTHOR"
METADATA_KEY_BT_FOLDER_TYPE
public static final String METADATA_KEY_BT_FOLDER_TYPE
The bluetooth folder type of the media specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5. It should be one of the following:
MediaDescription.BT_FOLDER_TYPE_MIXED
MediaDescription.BT_FOLDER_TYPE_TITLES
MediaDescription.BT_FOLDER_TYPE_ALBUMS
MediaDescription.BT_FOLDER_TYPE_ARTISTS
MediaDescription.BT_FOLDER_TYPE_GENRES
MediaDescription.BT_FOLDER_TYPE_PLAYLISTS
MediaDescription.BT_FOLDER_TYPE_YEARS
Constant Value: "android.media.metadata.BT_FOLDER_TYPE"
METADATA_KEY_COMPILATION
public static final String METADATA_KEY_COMPILATION
The compilation status of the media.
Constant Value: "android.media.metadata.COMPILATION"
METADATA_KEY_COMPOSER
public static final String METADATA_KEY_COMPOSER
The composer of the media.
Constant Value: "android.media.metadata.COMPOSER"
METADATA_KEY_DATE
public static final String METADATA_KEY_DATE
The date the media was created or published. The format is unspecified but RFC 3339 is recommended.
Constant Value: "android.media.metadata.DATE"
METADATA_KEY_DISC_NUMBER
public static final String METADATA_KEY_DISC_NUMBER
The disc number for the media's original source.
Constant Value: "android.media.metadata.DISC_NUMBER"
METADATA_KEY_DISPLAY_DESCRIPTION
public static final String METADATA_KEY_DISPLAY_DESCRIPTION
A 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.
Constant Value: "android.media.metadata.DISPLAY_DESCRIPTION"
METADATA_KEY_DISPLAY_ICON
public static final String METADATA_KEY_DISPLAY_ICON
An 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 Bitmap
.
The icon should be relatively small and may be scaled down by the system
if it is too large. For higher resolution artwork
METADATA_KEY_DISPLAY_ICON_URI
should be used instead.
Constant Value: "android.media.metadata.DISPLAY_ICON"
METADATA_KEY_DISPLAY_ICON_URI
public static final String METADATA_KEY_DISPLAY_ICON_URI
A 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
ContentResolver.openInputStream
and
BitmapFactory.decodeStream
.
For the best results, Uris should use the content:// style and support
ContentResolver.EXTRA_SIZE
for retrieving scaled artwork through
ContentResolver.openTypedAssetFileDescriptor(Uri, String, Bundle)
.
Constant Value: "android.media.metadata.DISPLAY_ICON_URI"
METADATA_KEY_DISPLAY_SUBTITLE
public static final String METADATA_KEY_DISPLAY_SUBTITLE
A 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.
Constant Value: "android.media.metadata.DISPLAY_SUBTITLE"
METADATA_KEY_DISPLAY_TITLE
public static final String METADATA_KEY_DISPLAY_TITLE
A title that is suitable for display to the user. This will generally be
the same as METADATA_KEY_TITLE
but may differ for some formats.
When displaying media described by this metadata this should be preferred
if present.
Constant Value: "android.media.metadata.DISPLAY_TITLE"
METADATA_KEY_DURATION
public static final String METADATA_KEY_DURATION
The duration of the media in ms. A negative duration indicates that the duration is unknown (or infinite).
Constant Value: "android.media.metadata.DURATION"
METADATA_KEY_GENRE
public static final String METADATA_KEY_GENRE
The genre of the media.
Constant Value: "android.media.metadata.GENRE"
METADATA_KEY_MEDIA_ID
public static final String METADATA_KEY_MEDIA_ID
A 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
MediaController.TransportControls.playFromMediaId(String, Bundle)
to initiate playback when provided by a MediaBrowser
connected to
the same app.
Constant Value: "android.media.metadata.MEDIA_ID"
METADATA_KEY_MEDIA_URI
public static final String METADATA_KEY_MEDIA_URI
A Uri formatted String representing the content. This value is specific to the
service providing the content. It may be used with
MediaController.TransportControls.playFromUri(Uri, Bundle)
to initiate playback when provided by a MediaBrowser
connected to
the same app.
Constant Value: "android.media.metadata.MEDIA_URI"
METADATA_KEY_NUM_TRACKS
public static final String METADATA_KEY_NUM_TRACKS
The number of tracks in the media's original source.
Constant Value: "android.media.metadata.NUM_TRACKS"
METADATA_KEY_RATING
public static final String METADATA_KEY_RATING
The overall rating for the media.
See also:
Constant Value: "android.media.metadata.RATING"
METADATA_KEY_TITLE
public static final String METADATA_KEY_TITLE
The title of the media.
Constant Value: "android.media.metadata.TITLE"
METADATA_KEY_TRACK_NUMBER
public static final String METADATA_KEY_TRACK_NUMBER
The track number for the media.
Constant Value: "android.media.metadata.TRACK_NUMBER"
METADATA_KEY_USER_RATING
public static final String METADATA_KEY_USER_RATING
The user's rating for the media.
See also:
Constant Value: "android.media.metadata.USER_RATING"
METADATA_KEY_WRITER
public static final String METADATA_KEY_WRITER
The writer of the media.
Constant Value: "android.media.metadata.WRITER"
METADATA_KEY_YEAR
public static final String METADATA_KEY_YEAR
The year the media was created or published as a long.
Constant Value: "android.media.metadata.YEAR"
Fields
Public methods
containsKey
public boolean containsKey (String key)
Returns true if the given key is contained in the metadata
Parameters | |
---|---|
key |
String : a String key |
Returns | |
---|---|
boolean |
true if the key exists in this metadata, false otherwise |
describeContents
public int describeContents ()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation. For example, if the object will
include a file descriptor in the output of writeToParcel(android.os.Parcel, int)
,
the return value of this method must include the
CONTENTS_FILE_DESCRIPTOR
bit.
Returns | |
---|---|
int |
a bitmask indicating the set of special object types marshaled
by this Parcelable object instance.
Value is either 0 or CONTENTS_FILE_DESCRIPTOR |
equals
public boolean equals (Object o)
Compares the contents of this object to another MediaMetadata object. It does not compare Bitmaps and Ratings as the media player can choose to forgo these fields depending on how you retrieve the MediaMetadata.
Parameters | |
---|---|
o |
Object : The Metadata object to compare this object against |
Returns | |
---|---|
boolean |
Whether or not the two objects have matching fields (excluding Bitmaps and Ratings) |
getBitmap
public Bitmap getBitmap (String key)
Returns a Bitmap
for the given key or null if no bitmap exists
for the given key.
Parameters | |
---|---|
key |
String : The key the value is stored under
Value is METADATA_KEY_ART , METADATA_KEY_ALBUM_ART , or METADATA_KEY_DISPLAY_ICON |
Returns | |
---|---|
Bitmap |
A Bitmap or null |
getBitmapDimensionLimit
public int getBitmapDimensionLimit ()
Gets the width/height limit (in pixels) for the bitmaps when this metadata was created. This method always returns a positive value.
If it returns Integer.MAX_VALUE
, then no scaling down was applied to the bitmaps
when this metadata was created.
If it returns another positive value, then all the bitmaps in this metadata has width/height not greater than this limit. Bitmaps may have been scaled down according to the limit.
Returns | |
---|---|
int |
Value is 1 or greater |
getDescription
public MediaDescription getDescription ()
Returns a simple description of this metadata for display purposes.
Returns | |
---|---|
MediaDescription |
A simple description of this metadata.
This value cannot be null . |
getLong
public long getLong (String key)
Returns the value associated with the given key, or 0L if no long exists for the given key.
Parameters | |
---|---|
key |
String : The key the value is stored under
Value is METADATA_KEY_DURATION , METADATA_KEY_YEAR , METADATA_KEY_TRACK_NUMBER , METADATA_KEY_NUM_TRACKS , METADATA_KEY_DISC_NUMBER , or METADATA_KEY_BT_FOLDER_TYPE |
Returns | |
---|---|
long |
a long value |
getRating
public Rating getRating (String key)
Returns a Rating
for the given key or null if no rating exists
for the given key.
Parameters | |
---|---|
key |
String : The key the value is stored under
Value is METADATA_KEY_USER_RATING , or METADATA_KEY_RATING |
Returns | |
---|---|
Rating |
A Rating or null |
getString
public String getString (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 getText().toString()
if the value is not null.
Parameters | |
---|---|
key |
String : The key the value is stored under
Value is METADATA_KEY_TITLE , METADATA_KEY_ARTIST , METADATA_KEY_ALBUM , METADATA_KEY_AUTHOR , METADATA_KEY_WRITER , METADATA_KEY_COMPOSER , METADATA_KEY_COMPILATION , METADATA_KEY_DATE , METADATA_KEY_GENRE , METADATA_KEY_ALBUM_ARTIST , METADATA_KEY_ART_URI , METADATA_KEY_ALBUM_ART_URI , METADATA_KEY_DISPLAY_TITLE , METADATA_KEY_DISPLAY_SUBTITLE , METADATA_KEY_DISPLAY_DESCRIPTION , METADATA_KEY_DISPLAY_ICON_URI , METADATA_KEY_MEDIA_ID , or METADATA_KEY_MEDIA_URI |
Returns | |
---|---|
String |
a String value, or null |
getText
public CharSequence getText (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.
Parameters | |
---|---|
key |
String : The key the value is stored under
Value is METADATA_KEY_TITLE , METADATA_KEY_ARTIST , METADATA_KEY_ALBUM , METADATA_KEY_AUTHOR , METADATA_KEY_WRITER , METADATA_KEY_COMPOSER , METADATA_KEY_COMPILATION , METADATA_KEY_DATE , METADATA_KEY_GENRE , METADATA_KEY_ALBUM_ARTIST , METADATA_KEY_ART_URI , METADATA_KEY_ALBUM_ART_URI , METADATA_KEY_DISPLAY_TITLE , METADATA_KEY_DISPLAY_SUBTITLE , METADATA_KEY_DISPLAY_DESCRIPTION , METADATA_KEY_DISPLAY_ICON_URI , METADATA_KEY_MEDIA_ID , or METADATA_KEY_MEDIA_URI |
Returns | |
---|---|
CharSequence |
a CharSequence value, or null |
hashCode
public int hashCode ()
Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
HashMap
.
The general contract of hashCode
is:
- Whenever it is invoked on the same object more than once during
an execution of a Java application, the
hashCode
method must consistently return the same integer, provided no information used inequals
comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two objects are equal according to the
equals
method, then calling thehashCode
method on each of the two objects must produce the same integer result. - It is not required that if two objects are unequal
according to the
equals
method, then calling thehashCode
method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns | |
---|---|
int |
a hash code value for this object. |
keySet
public Set<String> keySet ()
Returns a Set containing the Strings used as keys in this metadata.
Returns | |
---|---|
Set<String> |
a Set of String keys |
size
public int size ()
Returns the number of fields in this metadata.
Returns | |
---|---|
int |
The number of fields in the metadata. |
writeToParcel
public void writeToParcel (Parcel dest, int flags)
Flatten this object in to a Parcel.
Parameters | |
---|---|
dest |
Parcel : The Parcel in which the object should be written.
This value cannot be null . |
flags |
int : Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE .
Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-12-18 UTC.