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 |
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 |
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 |
containsKey(key: String!) Returns true if the given key is contained in the metadata |
Int | |
Boolean |
Compares the contents of this object to another MediaMetadata object. |
Bitmap! |
Returns a |
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 |
Returns the value associated with the given key, or 0L if no long exists for the given key. |
Rating! |
Returns a |
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! |
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() |
MutableSet<String!>! |
keySet() Returns a Set containing the Strings used as keys in this metadata. |
Int |
size() Returns the number of fields in this metadata. |
Unit |
writeToParcel(dest: Parcel, flags: Int) |
Properties | |
---|---|
static Parcelable.Creator<MediaMetadata!> |
Constants
METADATA_KEY_ALBUM
static val METADATA_KEY_ALBUM: String
The album title for the media.
Value: "android.media.metadata.ALBUM"
METADATA_KEY_ALBUM_ART
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
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
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
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
static val METADATA_KEY_ARTIST: String
The artist of the media.
Value: "android.media.metadata.ARTIST"
METADATA_KEY_ART_URI
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
static val METADATA_KEY_AUTHOR: String
The author of the media.
Value: "android.media.metadata.AUTHOR"
METADATA_KEY_BT_FOLDER_TYPE
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:
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
Value: "android.media.metadata.BT_FOLDER_TYPE"
METADATA_KEY_COMPILATION
static val METADATA_KEY_COMPILATION: String
The compilation status of the media.
Value: "android.media.metadata.COMPILATION"
METADATA_KEY_COMPOSER
static val METADATA_KEY_COMPOSER: String
The composer of the media.
Value: "android.media.metadata.COMPOSER"
METADATA_KEY_DATE
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
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
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
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
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
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
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
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
static val METADATA_KEY_GENRE: String
The genre of the media.
Value: "android.media.metadata.GENRE"
METADATA_KEY_MEDIA_ID
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
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
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
static val METADATA_KEY_RATING: String
The overall rating for the media.
Value: "android.media.metadata.RATING"
See Also
METADATA_KEY_TITLE
static val METADATA_KEY_TITLE: String
The title of the media.
Value: "android.media.metadata.TITLE"
METADATA_KEY_TRACK_NUMBER
static val METADATA_KEY_TRACK_NUMBER: String
The track number for the media.
Value: "android.media.metadata.TRACK_NUMBER"
METADATA_KEY_USER_RATING
static val METADATA_KEY_USER_RATING: String
The user's rating for the media.
Value: "android.media.metadata.USER_RATING"
See Also
METADATA_KEY_WRITER
static val METADATA_KEY_WRITER: String
The writer of the media.
Value: "android.media.metadata.WRITER"
METADATA_KEY_YEAR
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
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
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
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
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
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
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
fun getLong(key: String!): Long
Returns the value associated with the given key, or 0L if no long exists for the given key.
Return | |
---|---|
Long |
a long value |
getRating
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 |
getString
fun getString(key: String!): 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. This is equivalent to calling getText().toString()
if the value is not null.
Return | |
---|---|
String! |
a String value, or null |
getText
fun getText(key: String!): CharSequence!
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 | |
---|---|
CharSequence! |
a CharSequence value, or null |
keySet
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
fun size(): Int
Returns the number of fields in this metadata.
Return | |
---|---|
Int |
The number of fields in the metadata. |
writeToParcel
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 |