MediaItem2

open class MediaItem2
kotlin.Any
   ↳ androidx.media.MediaItem2

A class with information on a single media item with the metadata information. Media item are application dependent so we cannot guarantee that they contain the right values.

When it's sent to a controller or browser, it's anonymized and data descriptor wouldn't be sent.

This object isn't a thread safe.

Summary

Nested classes

Build MediaItem2

Constants
static Int

Flag: Indicates that the item has children of its own.

static Int

Flag: Indicates that the item is playable.

Public methods
open Boolean

Returns whether this item is playable.

open Int

open MediaMetadata2?

Returns the metadata of the media.

open Boolean
equals(other: Any?)

open String

open Bundle!

Return this object as a bundle to share between processes.

open Boolean

Returns whether this item is browsable.

open Int

Gets the flags of the item.

open Unit

Set a metadata.

open String!

Returns the media id for this item.

open DataSourceDesc?

Return the DataSourceDesc

open static MediaItem2!
fromBundle(bundle: Bundle!)

Create a MediaItem2 from the Bundle.

Constants

FLAG_BROWSABLE

static val FLAG_BROWSABLE: Int

Flag: Indicates that the item has children of its own.

Value: 1

FLAG_PLAYABLE

static val FLAG_PLAYABLE: Int

Flag: Indicates that the item is playable.

The id of this item may be passed to MediaController2#playFromMediaId(String, Bundle)

Value: 2

Public methods

isPlayable

open fun isPlayable(): Boolean

Returns whether this item is playable.

See Also

hashCode

open fun hashCode(): Int

getMetadata

open fun getMetadata(): MediaMetadata2?

Returns the metadata of the media.

equals

open fun equals(other: Any?): Boolean

toString

open fun toString(): String

toBundle

open fun toBundle(): Bundle!

Return this object as a bundle to share between processes.

Return
Bundle!: a new bundle instance

isBrowsable

open fun isBrowsable(): Boolean

Returns whether this item is browsable.

See Also

getFlags

open fun getFlags(): Int

Gets the flags of the item.

setMetadata

open fun setMetadata(metadata: MediaMetadata2?): Unit

Set a metadata. If the metadata is not null, its id should be matched with this instance's media id.

Parameters
metadata MediaMetadata2?: metadata to update

getMediaId

open fun getMediaId(): String!

Returns the media id for this item.

getDataSourceDesc

open fun getDataSourceDesc(): DataSourceDesc?

Return the DataSourceDesc

Can be null if the MediaItem2 came from another process and anonymized

Return
DataSourceDesc?: data source descriptor

fromBundle

open static fun fromBundle(bundle: Bundle!): MediaItem2!

Create a MediaItem2 from the Bundle.

Parameters
bundle Bundle!: The bundle which was published by MediaItem2#toBundle().
Return
MediaItem2!: The newly created MediaItem2