MediaMetadata

Added in 1.0.0
Deprecated in 1.3.0

public final class MediaMetadata implements VersionedParcelable


Contains metadata about an item, such as the title, artist, etc. This is optional, but you'd better to provide this as much as possible when you're using media widget and/or session APIs.

The media widget components build its UI based on the metadata here. For an example, will show title from the metadata.

The androidx.media2.session.MediaLibraryService.MediaLibrarySession would require some metadata values when it provides MediaItems to .

Topics covered here:

  1. Media ID
  2. Browsable type
  3. Playable
  4. Duration
  5. User rating

Media ID

If set, the media ID must be the persistent key for the underlying media contents, so and androidx.media2.session.MediaBrowser can store the information and reuse it later. Some APIs requires a media ID (e.g. setRating, so you'd better specify one.

Typical example of using media ID is the URI of the contents, but use it with the caution because the metadata is shared across the process in plain text.

The androidx.media2.session.MediaLibraryService.MediaLibrarySession would require it for the library root, so androidx.media2.session.MediaBrowser can call subsequent getChildren with the ID.

Browsable type

Browsable defines whether the media item has children and type of children if any. With this, androidx.media2.session.MediaBrowser can know whether the subsequent getChildren would successfully run.

The androidx.media2.session.MediaLibraryService.MediaLibrarySession would require the explicit browsable type for the media items returned by the .

Playable type

Playable defines whether the media item can be played or not. It may be possible for a playlist to contain a media item which isn't playable in order to show a disabled media item.

The androidx.media2.session.MediaLibraryService.MediaLibrarySession would require the explicit playable value for the media items returned by the .

Duration

The duration is the length of the contents. The androidx.media2.session.MediaController can only get the duration through the metadata. This tells when would the playback ends, and also tells about the allowed range of seekTo.

If it's not set by developer, androidx.media2.session.MediaSession would update the duration in the metadata with the getDuration.

User rating

Prefer to have unrated user rating instead of null, so can know the possible user rating type for calling setRating.

Summary

Nested types

public final class MediaMetadata.Builder

This class is deprecated.

androidx.media2 is deprecated.

Constants

static final long

The type of browsable that contains browsable items categorized by album.

static final long

The type of browsable that contains browsable items categorized by artist.

static final long

The type of browsable that contains browsable items categorized by genre.

static final long

The type of browsable that is unknown or contains media items of mixed types.

static final long

The type of browsable for non-browsable media item.

static final long

The type of browsable that contains browsable items categorized by playlist.

static final long

The type of browsable that only contains playable media items.

static final long

The type of browsable that contains browsable items categorized by year.

static final String
METADATA_KEY_ADVERTISEMENT = "androidx.media2.metadata.ADVERTISEMENT"

The metadata key for a Long typed value to retrieve the information about whether the media is an advertisement.

static final String
METADATA_KEY_ALBUM = "android.media.metadata.ALBUM"

The metadata key for a CharSequence or String typed value to retrieve the information about the album title for the media.

static final String
METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART"

The metadata key for a Bitmap typed value to retrieve the information about the artwork for the album of the media's original source.

static final String
METADATA_KEY_ALBUM_ARTIST = "android.media.metadata.ALBUM_ARTIST"

The metadata key for a CharSequence or String typed value to retrieve the information about the artist for the album of the media's original source.

static final String
METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about the Uri of the artwork for the album of the media's original source.

static final String
METADATA_KEY_ART = "android.media.metadata.ART"

The metadata key for a Bitmap typed value to retrieve the information about the artwork for the media.

static final String
METADATA_KEY_ARTIST = "android.media.metadata.ARTIST"

The metadata key for a CharSequence or String typed value to retrieve the information about the artist of the media.

static final String
METADATA_KEY_ART_URI = "android.media.metadata.ART_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about Uri of the artwork for the media.

static final String
METADATA_KEY_AUTHOR = "android.media.metadata.AUTHOR"

The metadata key for a CharSequence or String typed value to retrieve the information about the author of the media.

static final String
METADATA_KEY_BROWSABLE = "androidx.media2.metadata.BROWSABLE"

The metadata key for a Long typed value to retrieve the information about the type of browsable.

static final String
METADATA_KEY_COMPILATION = "android.media.metadata.COMPILATION"

The metadata key for a CharSequence or String typed value to retrieve the information about the compilation status of the media.

static final String
METADATA_KEY_COMPOSER = "android.media.metadata.COMPOSER"

The metadata key for a CharSequence or String typed value to retrieve the information about the composer of the media.

static final String
METADATA_KEY_DATE = "android.media.metadata.DATE"

The metadata key for a CharSequence or String typed value to retrieve the information about the date the media was created or published.

static final String
METADATA_KEY_DISC_NUMBER = "android.media.metadata.DISC_NUMBER"

The metadata key for a Long typed value to retrieve the information about the disc number for the media's original source.

static final String
METADATA_KEY_DISPLAY_DESCRIPTION = "android.media.metadata.DISPLAY_DESCRIPTION"

The metadata key for a CharSequence or String typed value to retrieve the information about the description that is suitable for display to the user.

static final String
METADATA_KEY_DISPLAY_ICON = "android.media.metadata.DISPLAY_ICON"

The metadata key for a Bitmap typed value to retrieve the information about the icon or thumbnail that is suitable for display to the user.

static final String
METADATA_KEY_DISPLAY_ICON_URI = "android.media.metadata.DISPLAY_ICON_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about the Uri of icon or thumbnail that is suitable for display to the user.

static final String
METADATA_KEY_DISPLAY_SUBTITLE = "android.media.metadata.DISPLAY_SUBTITLE"

The metadata key for a CharSequence or String typed value to retrieve the information about the subtitle that is suitable for display to the user.

static final String
METADATA_KEY_DISPLAY_TITLE = "android.media.metadata.DISPLAY_TITLE"

The metadata key for a CharSequence or String typed value to retrieve the information about the title that is suitable for display to the user.

static final String
METADATA_KEY_DOWNLOAD_STATUS = "androidx.media2.metadata.DOWNLOAD_STATUS"

The metadata key for a Long typed value to retrieve the information about the download status of the media which will be used for later offline playback.

static final String
METADATA_KEY_DURATION = "android.media.metadata.DURATION"

The metadata key for a Long typed value to retrieve the information about the duration of the media in ms.

static final String
METADATA_KEY_EXTRAS = "androidx.media2.metadata.EXTRAS"

A Bundle extra.

static final String
METADATA_KEY_GENRE = "android.media.metadata.GENRE"

The metadata key for a CharSequence or String typed value to retrieve the information about the genre of the media.

static final String
METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID"

The metadata key for a CharSequence or String typed value to retrieve the information about the media ID of the content.

static final String
METADATA_KEY_MEDIA_URI = "android.media.metadata.MEDIA_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about the Uri of the content.

static final String
METADATA_KEY_NUM_TRACKS = "android.media.metadata.NUM_TRACKS"

The metadata key for a Long typed value to retrieve the information about the number of tracks in the media's original source.

static final String
METADATA_KEY_PLAYABLE = "androidx.media2.metadata.PLAYABLE"

The metadata key for a Long typed value to retrieve the information about whether the media is playable.

static final String
METADATA_KEY_RATING = "android.media.metadata.RATING"

The metadata key for a Rating typed value to retrieve the information about the overall rating for the media.

static final String
METADATA_KEY_TITLE = "android.media.metadata.TITLE"

The metadata key for a CharSequence or String typed value to retrieve the information about the title of the media.

static final String
METADATA_KEY_TRACK_NUMBER = "android.media.metadata.TRACK_NUMBER"

The metadata key for a Long typed value to retrieve the information about the track number for the media.

static final String
METADATA_KEY_USER_RATING = "android.media.metadata.USER_RATING"

The metadata key for a Rating typed value to retrieve the information about the user's rating for the media.

static final String
METADATA_KEY_WRITER = "android.media.metadata.WRITER"

The metadata key for a CharSequence or String typed value to retrieve the information about the writer of the media.

static final String
METADATA_KEY_YEAR = "android.media.metadata.YEAR"

The metadata key for a Long typed value to retrieve the information about the year the media was created or published.

static final long

The status value to indicate the media item is downloaded for later offline playback.

static final long

The status value to indicate the media item is being downloaded.

static final long

The status value to indicate the media item is not downloaded.

Public methods

boolean

Returns true if the given key is contained in the metadata

@Nullable Bitmap

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

@Nullable Bundle

Get the extra Bundle from the metadata object.

float

Return the value associated with the given key, or 0.0f if no long exists for the given key.

long

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

@Nullable String

Returns the media id, or null if the id doesn't exist.

@Nullable Rating

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

@Nullable 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.

@Nullable 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.

@NonNull Set<String>

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

int

Get the number of fields in this metadata.

String

Constants

BROWSABLE_TYPE_ALBUMS

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_ALBUMS = 2

The type of browsable that contains browsable items categorized by album.

This value matches with the folder type 'Albums' as specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

BROWSABLE_TYPE_ARTISTS

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_ARTISTS = 3

The type of browsable that contains browsable items categorized by artist.

This value matches with the folder type 'Artists' as specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

BROWSABLE_TYPE_GENRES

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_GENRES = 4

The type of browsable that contains browsable items categorized by genre.

This value matches with the folder type 'Genres' as specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

BROWSABLE_TYPE_MIXED

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_MIXED = 0

The type of browsable that is unknown or contains media items of mixed types.

This value matches with the folder type 'Mixed' as specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

BROWSABLE_TYPE_NONE

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_NONE = -1

The type of browsable for non-browsable media item.

BROWSABLE_TYPE_PLAYLISTS

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_PLAYLISTS = 5

The type of browsable that contains browsable items categorized by playlist.

This value matches with the folder type 'Playlists' as specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

BROWSABLE_TYPE_TITLES

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_TITLES = 1

The type of browsable that only contains playable media items.

This value matches with the folder type 'Titles' as specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

BROWSABLE_TYPE_YEARS

Added in 1.0.0
Deprecated in 1.3.0
public static final long BROWSABLE_TYPE_YEARS = 6

The type of browsable that contains browsable items categorized by year.

This value matches with the folder type 'Years' as specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

METADATA_KEY_ADVERTISEMENT

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ADVERTISEMENT = "androidx.media2.metadata.ADVERTISEMENT"

The metadata key for a Long typed value to retrieve the information about 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.

See also
putLong
getLong

METADATA_KEY_ALBUM

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ALBUM = "android.media.metadata.ALBUM"

The metadata key for a CharSequence or String typed value to retrieve the information about the album title for the media.

METADATA_KEY_ALBUM_ART

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ALBUM_ART = "android.media.metadata.ALBUM_ART"

The metadata key for a Bitmap typed value to retrieve the information about the artwork for the album of the media's original source. 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.

See also
putBitmap
getBitmap

METADATA_KEY_ALBUM_ARTIST

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ALBUM_ARTIST = "android.media.metadata.ALBUM_ARTIST"

The metadata key for a CharSequence or String typed value to retrieve the information about the artist for the album of the media's original source.

METADATA_KEY_ALBUM_ART_URI

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ALBUM_ART_URI = "android.media.metadata.ALBUM_ART_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about the Uri of the artwork for the album of the media's original source.

METADATA_KEY_ART

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ART = "android.media.metadata.ART"

The metadata key for a Bitmap typed value to retrieve the information about the artwork for the media. 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.

See also
putBitmap
getBitmap

METADATA_KEY_ARTIST

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ARTIST = "android.media.metadata.ARTIST"

The metadata key for a CharSequence or String typed value to retrieve the information about the artist of the media.

METADATA_KEY_ART_URI

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_ART_URI = "android.media.metadata.ART_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about Uri of the artwork for the media.

METADATA_KEY_AUTHOR

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_AUTHOR = "android.media.metadata.AUTHOR"

The metadata key for a CharSequence or String typed value to retrieve the information about the author of the media.

METADATA_KEY_BROWSABLE

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_BROWSABLE = "androidx.media2.metadata.BROWSABLE"

The metadata key for a Long typed value to retrieve the information about the type of browsable. It should be one of the following:

The values other than BROWSABLE_TYPE_NONE mean that the media item has children.[

This matches with the bluetooth folder type of the media specified in the section 6.10.2.2 of the Bluetooth AVRCP 1.5.

METADATA_KEY_COMPILATION

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_COMPILATION = "android.media.metadata.COMPILATION"

The metadata key for a CharSequence or String typed value to retrieve the information about the compilation status of the media.

METADATA_KEY_COMPOSER

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_COMPOSER = "android.media.metadata.COMPOSER"

The metadata key for a CharSequence or String typed value to retrieve the information about the composer of the media.

METADATA_KEY_DATE

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DATE = "android.media.metadata.DATE"

The metadata key for a CharSequence or String typed value to retrieve the information about the date the media was created or published. The format is unspecified but RFC 3339 is recommended.

METADATA_KEY_DISC_NUMBER

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DISC_NUMBER = "android.media.metadata.DISC_NUMBER"

The metadata key for a Long typed value to retrieve the information about the disc number for the media's original source.

See also
putLong
getLong

METADATA_KEY_DISPLAY_DESCRIPTION

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DISPLAY_DESCRIPTION = "android.media.metadata.DISPLAY_DESCRIPTION"

The metadata key for a CharSequence or String typed value to retrieve the information about the 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.

METADATA_KEY_DISPLAY_ICON

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DISPLAY_ICON = "android.media.metadata.DISPLAY_ICON"

The metadata key for a Bitmap typed value to retrieve the information about the 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.

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.

See also
putBitmap
getBitmap

METADATA_KEY_DISPLAY_ICON_URI

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DISPLAY_ICON_URI = "android.media.metadata.DISPLAY_ICON_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about the Uri of 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.

METADATA_KEY_DISPLAY_SUBTITLE

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DISPLAY_SUBTITLE = "android.media.metadata.DISPLAY_SUBTITLE"

The metadata key for a CharSequence or String typed value to retrieve the information about the 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.

METADATA_KEY_DISPLAY_TITLE

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DISPLAY_TITLE = "android.media.metadata.DISPLAY_TITLE"

The metadata key for a CharSequence or String typed value to retrieve the information about the title that is suitable for display to the user. It 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.

METADATA_KEY_DOWNLOAD_STATUS

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DOWNLOAD_STATUS = "androidx.media2.metadata.DOWNLOAD_STATUS"

The metadata key for a Long typed value to retrieve the information about the download status of the media which will be used for later offline playback. It should be one of the following:

See also
putLong
getLong

METADATA_KEY_DURATION

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_DURATION = "android.media.metadata.DURATION"

The metadata key for a Long typed value to retrieve the information about the duration of the media in ms. A negative duration indicates that the duration is unknown (or infinite).

See also
putLong
getLong

METADATA_KEY_EXTRAS

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_EXTRAS = "androidx.media2.metadata.EXTRAS"

A Bundle extra.

METADATA_KEY_GENRE

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_GENRE = "android.media.metadata.GENRE"

The metadata key for a CharSequence or String typed value to retrieve the information about the genre of the media.

METADATA_KEY_MEDIA_ID

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_MEDIA_ID = "android.media.metadata.MEDIA_ID"

The metadata key for a CharSequence or String typed value to retrieve the information about the media ID of the content. This value is specific to the service providing the content. If used, this should be a persistent key for the underlying content. This ID is used by androidx.media2.session.MediaController and androidx.media2.session.MediaBrowser.

METADATA_KEY_MEDIA_URI

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_MEDIA_URI = "android.media.metadata.MEDIA_URI"

The metadata key for a CharSequence or String typed value to retrieve the information about the Uri of the content. This value is specific to the service providing the content.

METADATA_KEY_NUM_TRACKS

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_NUM_TRACKS = "android.media.metadata.NUM_TRACKS"

The metadata key for a Long typed value to retrieve the information about the number of tracks in the media's original source.

See also
putLong
getLong

METADATA_KEY_PLAYABLE

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_PLAYABLE = "androidx.media2.metadata.PLAYABLE"

The metadata key for a Long typed value to retrieve the information about whether the media is playable. A value of 0 indicates it is not a playable item. A value of 1 or non-zero indicates it is playable.

METADATA_KEY_RATING

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_RATING = "android.media.metadata.RATING"

The metadata key for a Rating typed value to retrieve the information about the overall rating for the media.

See also
putRating
getRating

METADATA_KEY_TITLE

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_TITLE = "android.media.metadata.TITLE"

The metadata key for a CharSequence or String typed value to retrieve the information about the title of the media.

METADATA_KEY_TRACK_NUMBER

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_TRACK_NUMBER = "android.media.metadata.TRACK_NUMBER"

The metadata key for a Long typed value to retrieve the information about the track number for the media.

See also
putLong
getLong

METADATA_KEY_USER_RATING

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_USER_RATING = "android.media.metadata.USER_RATING"

The metadata key for a Rating typed value to retrieve the information about the user's rating for the media. Prefer to have unrated user rating instead of null, so androidx.media2.session.MediaController can know the possible user rating type.

METADATA_KEY_WRITER

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_WRITER = "android.media.metadata.WRITER"

The metadata key for a CharSequence or String typed value to retrieve the information about the writer of the media.

METADATA_KEY_YEAR

Added in 1.0.0
Deprecated in 1.3.0
public static final String METADATA_KEY_YEAR = "android.media.metadata.YEAR"

The metadata key for a Long typed value to retrieve the information about the year the media was created or published.

See also
putLong
getLong

STATUS_DOWNLOADED

Added in 1.0.0
Deprecated in 1.3.0
public static final long STATUS_DOWNLOADED = 2

The status value to indicate the media item is downloaded for later offline playback.

STATUS_DOWNLOADING

Added in 1.0.0
Deprecated in 1.3.0
public static final long STATUS_DOWNLOADING = 1

The status value to indicate the media item is being downloaded.

STATUS_NOT_DOWNLOADED

Added in 1.0.0
Deprecated in 1.3.0
public static final long STATUS_NOT_DOWNLOADED = 0

The status value to indicate the media item is not downloaded.

Public methods

containsKey

Added in 1.0.0
Deprecated in 1.3.0
public boolean containsKey(@NonNull String key)

Returns true if the given key is contained in the metadata

Parameters
@NonNull String key

a String key

Returns
boolean

true if the key exists in this metadata, false otherwise

getBitmap

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Bitmap getBitmap(@NonNull String key)

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

Parameters
@NonNull String key

The key the value is stored under

Returns
@Nullable Bitmap

A Bitmap or null

getExtras

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Bundle getExtras()

Get the extra Bundle from the metadata object.

Returns
@Nullable Bundle

A Bundle or null

getFloat

Added in 1.0.0
Deprecated in 1.3.0
public float getFloat(@NonNull String key)

Return the value associated with the given key, or 0.0f if no long exists for the given key.

Parameters
@NonNull String key

The key the value is stored under

Returns
float

a float value

getLong

Added in 1.0.0
Deprecated in 1.3.0
public long getLong(@NonNull String key)

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

Parameters
@NonNull String key

The key the value is stored under

Returns
long

a long value

getMediaId

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable String getMediaId()

Returns the media id, or null if the id doesn't exist.

This is equivalent to the getString with the METADATA_KEY_MEDIA_ID.

Returns
@Nullable String

media id. Can be null

getRating

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Rating getRating(@NonNull String key)

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

For the METADATA_KEY_USER_RATING, A null return value means that user rating cannot be set by androidx.media2.session.MediaController.

Parameters
@NonNull String key

The key the value is stored under

Returns
@Nullable Rating

A Rating or null

getString

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable String getString(@NonNull 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
@NonNull String key

The key the value is stored under

Returns
@Nullable String

a String value, or null

getText

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable CharSequence getText(@NonNull 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
@NonNull String key

The key the value is stored under

Returns
@Nullable CharSequence

a CharSequence value, or null

keySet

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull Set<StringkeySet()

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

Returns
@NonNull Set<String>

a Set of String keys

size

Added in 1.0.0
Deprecated in 1.3.0
public int size()

Get the number of fields in this metadata.

Returns
int

The number of fields in the metadata.

toString

public String toString()