belongs to Maven artifact com.android.support:support-media-compat:28.0.0-alpha1
MediaMetadataCompat
public
final
class
MediaMetadataCompat
extends Object
implements
Parcelable
java.lang.Object | |
↳ | android.support.v4.media.MediaMetadataCompat |
Contains metadata about an item, such as the title, artist, etc.
Summary
Nested classes | |
---|---|
class |
MediaMetadataCompat.Builder
Use to build MediaMetadata objects. |
Constants | |
---|---|
String |
METADATA_KEY_ADVERTISEMENT
Whether the media is an advertisement. |
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 style 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 style 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
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_DOWNLOAD_STATUS
The download status of the media which will be used for later offline playback. |
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 |
---|
From
interface
android.os.Parcelable
|
Fields | |
---|---|
public
static
final
Creator<MediaMetadataCompat> |
CREATOR
|
Public methods | |
---|---|
boolean
|
containsKey(String key)
Returns true if the given key is contained in the metadata |
int
|
describeContents()
|
static
MediaMetadataCompat
|
fromMediaMetadata(Object metadataObj)
Creates an instance from a framework |
Bitmap
|
getBitmap(String key)
Return a |
Bundle
|
getBundle()
Gets the bundle backing the metadata object. |
MediaDescriptionCompat
|
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. |
Object
|
getMediaMetadata()
Gets the underlying framework |
RatingCompat
|
getRating(String key)
Return a |
String
|
getString(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
|
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. |
Set<String>
|
keySet()
Returns a Set containing the Strings used as keys in this metadata. |
int
|
size()
Get the number of fields in this metadata. |
void
|
writeToParcel(Parcel dest, int flags)
|
Inherited methods | |
---|---|
From
class
java.lang.Object
| |
From
interface
android.os.Parcelable
|
Constants
METADATA_KEY_ADVERTISEMENT
String METADATA_KEY_ADVERTISEMENT
Whether the media is an advertisement. A value of 0 indicates it is not an advertisement. A value of 1 or non-zero indicates it is an advertisement. If not specified, this value is set to 0 by default.
Constant Value: "android.media.metadata.ADVERTISEMENT"
METADATA_KEY_ALBUM
String METADATA_KEY_ALBUM
The album title for the media.
Constant Value: "android.media.metadata.ALBUM"
METADATA_KEY_ALBUM_ART
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
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
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
String METADATA_KEY_ALBUM_ART_URI
The artwork for the album of the media's original source as a Uri style String.
Constant Value: "android.media.metadata.ALBUM_ART_URI"
METADATA_KEY_ART
String METADATA_KEY_ART
The artwork for the media as a Bitmap
.
The artwork should be relatively small and may be scaled down
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
String METADATA_KEY_ARTIST
The artist of the media.
Constant Value: "android.media.metadata.ARTIST"
METADATA_KEY_ART_URI
String METADATA_KEY_ART_URI
The artwork for the media as a Uri style String.
Constant Value: "android.media.metadata.ART_URI"
METADATA_KEY_AUTHOR
String METADATA_KEY_AUTHOR
The author of the media.
Constant Value: "android.media.metadata.AUTHOR"
METADATA_KEY_BT_FOLDER_TYPE
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:
BT_FOLDER_TYPE_MIXED
BT_FOLDER_TYPE_TITLES
BT_FOLDER_TYPE_ALBUMS
BT_FOLDER_TYPE_ARTISTS
BT_FOLDER_TYPE_GENRES
BT_FOLDER_TYPE_PLAYLISTS
BT_FOLDER_TYPE_YEARS
Constant Value: "android.media.metadata.BT_FOLDER_TYPE"
METADATA_KEY_COMPILATION
String METADATA_KEY_COMPILATION
The compilation status of the media.
Constant Value: "android.media.metadata.COMPILATION"
METADATA_KEY_COMPOSER
String METADATA_KEY_COMPOSER
The composer of the media.
Constant Value: "android.media.metadata.COMPOSER"
METADATA_KEY_DATE
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
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
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
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
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
String METADATA_KEY_DISPLAY_ICON_URI
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. This must be a Uri style String.
Constant Value: "android.media.metadata.DISPLAY_ICON_URI"
METADATA_KEY_DISPLAY_SUBTITLE
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
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_DOWNLOAD_STATUS
String METADATA_KEY_DOWNLOAD_STATUS
The download status of the media which will be used for later offline playback. It should be one of the following:
Constant Value: "android.media.metadata.DOWNLOAD_STATUS"
METADATA_KEY_DURATION
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
String METADATA_KEY_GENRE
The genre of the media.
Constant Value: "android.media.metadata.GENRE"
METADATA_KEY_MEDIA_ID
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.
Constant Value: "android.media.metadata.MEDIA_ID"
METADATA_KEY_MEDIA_URI
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
playFromUri(Uri, Bundle)
to initiate playback when provided by a MediaBrowserCompat
connected to
the same app.
Constant Value: "android.media.metadata.MEDIA_URI"
METADATA_KEY_NUM_TRACKS
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
String METADATA_KEY_RATING
The overall rating for the media.
See also:
Constant Value: "android.media.metadata.RATING"
METADATA_KEY_TITLE
String METADATA_KEY_TITLE
The title of the media.
Constant Value: "android.media.metadata.TITLE"
METADATA_KEY_TRACK_NUMBER
String METADATA_KEY_TRACK_NUMBER
The track number for the media.
Constant Value: "android.media.metadata.TRACK_NUMBER"
METADATA_KEY_USER_RATING
String METADATA_KEY_USER_RATING
The user's rating for the media.
See also:
Constant Value: "android.media.metadata.USER_RATING"
METADATA_KEY_WRITER
String METADATA_KEY_WRITER
The writer of the media.
Constant Value: "android.media.metadata.WRITER"
METADATA_KEY_YEAR
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
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 |
fromMediaMetadata
MediaMetadataCompat fromMediaMetadata (Object metadataObj)
Creates an instance from a framework MediaMetadata
object.
This method is only supported on
LOLLIPOP
and later.
Parameters | |
---|---|
metadataObj |
Object : A MediaMetadata object, or null
if none. |
Returns | |
---|---|
MediaMetadataCompat |
An equivalent MediaMetadataCompat object, or null if
none.
|
getBitmap
Bitmap getBitmap (String key)
Return 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 |
Returns | |
---|---|
Bitmap |
A Bitmap or null
|
getBundle
Bundle getBundle ()
Gets the bundle backing the metadata object. This is available to support backwards compatibility. Apps should not modify the bundle directly.
Returns | |
---|---|
Bundle |
The Bundle backing this metadata. |
getDescription
MediaDescriptionCompat getDescription ()
Returns a simple description of this metadata for display purposes.
Returns | |
---|---|
MediaDescriptionCompat |
A simple description of this metadata. |
getLong
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 |
Returns | |
---|---|
long |
a long value |
getMediaMetadata
Object getMediaMetadata ()
Gets the underlying framework MediaMetadata
object.
This method is only supported on
LOLLIPOP
and later.
Returns | |
---|---|
Object |
An equivalent MediaMetadata object, or null
if none.
|
getRating
RatingCompat getRating (String key)
Return a RatingCompat
for the given key or null if no rating exists for
the given key.
Parameters | |
---|---|
key |
String : The key the value is stored under |
Returns | |
---|---|
RatingCompat |
A RatingCompat or null
|
getString
String getString (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 |
Returns | |
---|---|
String |
a String value, or null |
getText
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 |
Returns | |
---|---|
CharSequence |
a CharSequence value, or null |
keySet
Set<String> keySet ()
Returns a Set containing the Strings used as keys in this metadata.
Returns | |
---|---|
Set<String> |
a Set of String keys |
size
int size ()
Get the number of fields in this metadata.
Returns | |
---|---|
int |
The number of fields in the metadata. |
writeToParcel
void writeToParcel (Parcel dest, int flags)
Parameters | |
---|---|
dest |
Parcel |
flags |
int |
Classes
- AudioAttributesCompat
- AudioAttributesCompat.Builder
- MediaBrowserCompat
- MediaBrowserCompat.ConnectionCallback
- MediaBrowserCompat.CustomActionCallback
- MediaBrowserCompat.ItemCallback
- MediaBrowserCompat.MediaItem
- MediaBrowserCompat.SearchCallback
- MediaBrowserCompat.SubscriptionCallback
- MediaBrowserServiceCompat
- MediaBrowserServiceCompat.BrowserRoot
- MediaBrowserServiceCompat.Result
- MediaDescriptionCompat
- MediaDescriptionCompat.Builder
- MediaMetadataCompat
- MediaMetadataCompat.Builder
- RatingCompat
- VolumeProviderCompat
- VolumeProviderCompat.Callback
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-04-11 UTC.