Added in API level 21

MediaMetadata

class MediaMetadata : Parcelable
kotlin.Any
   ↳ android.media.MediaMetadata

Contains metadata about an item, such as the title, artist, etc.

Summary

Nested classes

Use to build MediaMetadata objects.

Constants
static String

The album title for the media.

static String

The artwork for the album of the media's original source as a Bitmap.

static String

The artist for the album of the media's original source.

static String

The artwork for the album of the media's original source as a Uri formatted String.

static String

The artwork for the media as a Bitmap.

static String

The artist of the media.

static String

The artwork for the media as a Uri formatted String.

static String

The author of the media.

static String

The bluetooth folder type of the media specified in the section 6.

static String

The compilation status of the media.

static String

The composer of the media.

static String

The date the media was created or published.

static String

The disc number for the media's original source.

static String

A description that is suitable for display to the user.

static String

An icon or thumbnail that is suitable for display to the user.

static String

A Uri formatted String for an icon or thumbnail that is suitable for display to the user.

static String

A subtitle that is suitable for display to the user.

static String

A title that is suitable for display to the user.

static String

The duration of the media in ms.

static String

The genre of the media.

static String

A String key for identifying the content.

static String

A Uri formatted String representing the content.

static String

The number of tracks in the media's original source.

static String

The overall rating for the media.

static String

The title of the media.

static String

The track number for the media.

static String

The user's rating for the media.

static String

The writer of the media.

static String

The year the media was created or published as a long.

Inherited constants
Public methods
Boolean

Returns true if the given key is contained in the metadata

Int

Boolean
equals(other: Any?)

Compares the contents of this object to another MediaMetadata object.

Bitmap!

Returns a Bitmap for the given key or null if no bitmap exists for the given key.

Int

Gets the width/height limit (in pixels) for the bitmaps when this metadata was created.

MediaDescription

Returns a simple description of this metadata for display purposes.

Long
getLong(key: String!)

Returns the value associated with the given key, or 0L if no long exists for the given key.

Rating!

Returns a Rating for the given key or null if no rating exists for the given key.

String!

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(key: String!)

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

MutableSet<String!>!

Returns a Set containing the Strings used as keys in this metadata.

Int

Returns the number of fields in this metadata.

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<MediaMetadata!>

Constants

METADATA_KEY_ALBUM

Added in API level 21
static val METADATA_KEY_ALBUM: String

The album title for the media.

Value: "android.media.metadata.ALBUM"

METADATA_KEY_ALBUM_ART

Added in API level 21
static val METADATA_KEY_ALBUM_ART: String

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.

Value: "android.media.metadata.ALBUM_ART"

METADATA_KEY_ALBUM_ARTIST

Added in API level 21
static val METADATA_KEY_ALBUM_ARTIST: String

The artist for the album of the media's original source.

Value: "android.media.metadata.ALBUM_ARTIST"

METADATA_KEY_ALBUM_ART_URI

Added in API level 21
static val METADATA_KEY_ALBUM_ART_URI: String

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 android.graphics.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).

Value: "android.media.metadata.ALBUM_ART_URI"

METADATA_KEY_ART

Added in API level 21
static val METADATA_KEY_ART: String

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.

Value: "android.media.metadata.ART"

METADATA_KEY_ARTIST

Added in API level 21
static val METADATA_KEY_ARTIST: String

The artist of the media.

Value: "android.media.metadata.ARTIST"

METADATA_KEY_ART_URI

Added in API level 21
static val METADATA_KEY_ART_URI: String

The artwork for the media as a Uri formatted String. The artwork can be loaded using a combination of ContentResolver#openInputStream and android.graphics.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).

Value: "android.media.metadata.ART_URI"

METADATA_KEY_AUTHOR

Added in API level 21
static val METADATA_KEY_AUTHOR: String

The author of the media.

Value: "android.media.metadata.AUTHOR"

METADATA_KEY_BT_FOLDER_TYPE

Added in API level 26
static val METADATA_KEY_BT_FOLDER_TYPE: String

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:

Value: "android.media.metadata.BT_FOLDER_TYPE"

METADATA_KEY_COMPILATION

Added in API level 21
static val METADATA_KEY_COMPILATION: String

The compilation status of the media.

Value: "android.media.metadata.COMPILATION"

METADATA_KEY_COMPOSER

Added in API level 21
static val METADATA_KEY_COMPOSER: String

The composer of the media.

Value: "android.media.metadata.COMPOSER"

METADATA_KEY_DATE

Added in API level 21
static val METADATA_KEY_DATE: String

The date the media was created or published. The format is unspecified but RFC 3339 is recommended.

Value: "android.media.metadata.DATE"

METADATA_KEY_DISC_NUMBER

Added in API level 21
static val METADATA_KEY_DISC_NUMBER: String

The disc number for the media's original source.

Value: "android.media.metadata.DISC_NUMBER"

METADATA_KEY_DISPLAY_DESCRIPTION

Added in API level 21
static val METADATA_KEY_DISPLAY_DESCRIPTION: String

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.

Value: "android.media.metadata.DISPLAY_DESCRIPTION"

METADATA_KEY_DISPLAY_ICON

Added in API level 21
static val METADATA_KEY_DISPLAY_ICON: String

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.

Value: "android.media.metadata.DISPLAY_ICON"

METADATA_KEY_DISPLAY_ICON_URI

Added in API level 21
static val METADATA_KEY_DISPLAY_ICON_URI: String

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 android.graphics.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).

Value: "android.media.metadata.DISPLAY_ICON_URI"

METADATA_KEY_DISPLAY_SUBTITLE

Added in API level 21
static val METADATA_KEY_DISPLAY_SUBTITLE: String

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.

Value: "android.media.metadata.DISPLAY_SUBTITLE"

METADATA_KEY_DISPLAY_TITLE

Added in API level 21
static val METADATA_KEY_DISPLAY_TITLE: String

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.

Value: "android.media.metadata.DISPLAY_TITLE"

METADATA_KEY_DURATION

Added in API level 21
static val METADATA_KEY_DURATION: String

The duration of the media in ms. A negative duration indicates that the duration is unknown (or infinite).

Value: "android.media.metadata.DURATION"

METADATA_KEY_GENRE

Added in API level 21
static val METADATA_KEY_GENRE: String

The genre of the media.

Value: "android.media.metadata.GENRE"

METADATA_KEY_MEDIA_ID

Added in API level 21
static val METADATA_KEY_MEDIA_ID: String

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.

Value: "android.media.metadata.MEDIA_ID"

METADATA_KEY_MEDIA_URI

Added in API level 26
static val METADATA_KEY_MEDIA_URI: String

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.

Value: "android.media.metadata.MEDIA_URI"

METADATA_KEY_NUM_TRACKS

Added in API level 21
static val METADATA_KEY_NUM_TRACKS: String

The number of tracks in the media's original source.

Value: "android.media.metadata.NUM_TRACKS"

METADATA_KEY_RATING

Added in API level 21
static val METADATA_KEY_RATING: String

The overall rating for the media.

Value: "android.media.metadata.RATING"

METADATA_KEY_TITLE

Added in API level 21
static val METADATA_KEY_TITLE: String

The title of the media.

Value: "android.media.metadata.TITLE"

METADATA_KEY_TRACK_NUMBER

Added in API level 21
static val METADATA_KEY_TRACK_NUMBER: String

The track number for the media.

Value: "android.media.metadata.TRACK_NUMBER"

METADATA_KEY_USER_RATING

Added in API level 21
static val METADATA_KEY_USER_RATING: String

The user's rating for the media.

Value: "android.media.metadata.USER_RATING"

METADATA_KEY_WRITER

Added in API level 21
static val METADATA_KEY_WRITER: String

The writer of the media.

Value: "android.media.metadata.WRITER"

METADATA_KEY_YEAR

Added in API level 21
static val METADATA_KEY_YEAR: String

The year the media was created or published as a long.

Value: "android.media.metadata.YEAR"

Public methods

containsKey

Added in API level 21
fun containsKey(key: String!): Boolean

Returns true if the given key is contained in the metadata

Parameters
key String!: a String key
Return
Boolean true if the key exists in this metadata, false otherwise

describeContents

Added in API level 21
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 21
fun equals(other: Any?): Boolean

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
obj the reference object with which to compare.
o The Metadata object to compare this object against
Return
Boolean Whether or not the two objects have matching fields (excluding Bitmaps and Ratings)

getBitmap

Added in API level 21
fun getBitmap(key: String!): Bitmap!

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 android.media.MediaMetadata#METADATA_KEY_ART, android.media.MediaMetadata#METADATA_KEY_ALBUM_ART, or android.media.MediaMetadata#METADATA_KEY_DISPLAY_ICON
Return
Bitmap! A Bitmap or null

getBitmapDimensionLimit

Added in API level 31
fun getBitmapDimensionLimit(): Int

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.

Return
Int Value is 1 or greater

getDescription

Added in API level 21
fun getDescription(): MediaDescription

Returns a simple description of this metadata for display purposes.

Return
MediaDescription A simple description of this metadata. This value cannot be null.

getLong

Added in API level 21
fun getLong(key: String!): Long

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 android.media.MediaMetadata#METADATA_KEY_DURATION, android.media.MediaMetadata#METADATA_KEY_YEAR, android.media.MediaMetadata#METADATA_KEY_TRACK_NUMBER, android.media.MediaMetadata#METADATA_KEY_NUM_TRACKS, android.media.MediaMetadata#METADATA_KEY_DISC_NUMBER, or android.media.MediaMetadata#METADATA_KEY_BT_FOLDER_TYPE
Return
Long a long value

getRating

Added in API level 21
fun getRating(key: String!): Rating!

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 android.media.MediaMetadata#METADATA_KEY_USER_RATING, or android.media.MediaMetadata#METADATA_KEY_RATING
Return
Rating! A Rating or null

hashCode

Added in API level 21
fun hashCode(): Int
Return
Int a hash code value for this object.

keySet

Added in API level 21
fun keySet(): MutableSet<String!>!

Returns a Set containing the Strings used as keys in this metadata.

Return
MutableSet<String!>! a Set of String keys

size

Added in API level 21
fun size(): Int

Returns the number of fields in this metadata.

Return
Int The number of fields in the metadata.

writeToParcel

Added in API level 21
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
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_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 21
static val CREATOR: Parcelable.Creator<MediaMetadata!>