MediaItem2

public class MediaItem2
extends Object implements VersionedParcelable

java.lang.Object
   ↳ androidx.media2.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

class MediaItem2.Builder

Builder for MediaItem2  

Constants

int FLAG_BROWSABLE

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

int FLAG_PLAYABLE

Flag: Indicates that the item is playable.

Public methods

boolean equals(Object obj)
DataSourceDesc2 getDataSourceDesc()

Return the DataSourceDesc2

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

int getFlags()

Gets the flags of the item.

String getMediaId()

Returns the media id for this item.

MediaMetadata2 getMetadata()

Returns the metadata of the media.

int hashCode()
boolean isBrowsable()

Returns whether this item is browsable.

boolean isPlayable()

Returns whether this item is playable.

void setMetadata(MediaMetadata2 metadata)

Set a metadata.

String toString()

Inherited methods

Constants

FLAG_BROWSABLE

public static final int FLAG_BROWSABLE

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

Constant Value: 1 (0x00000001)

FLAG_PLAYABLE

public static final int FLAG_PLAYABLE

Flag: Indicates that the item is playable.

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

Constant Value: 2 (0x00000002)

Public methods

equals

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

getDataSourceDesc

public DataSourceDesc2 getDataSourceDesc ()

Return the DataSourceDesc2

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

Returns
DataSourceDesc2 data source descriptor

getFlags

public int getFlags ()

Gets the flags of the item.

Returns
int

getMediaId

public String getMediaId ()

Returns the media id for this item. If it's not null, it's a persistent unique key for the underlying media content.

Returns
String media Id from the session

getMetadata

public MediaMetadata2 getMetadata ()

Returns the metadata of the media.

Returns
MediaMetadata2 metadata from the session

hashCode

public int hashCode ()

Returns
int

isBrowsable

public boolean isBrowsable ()

Returns whether this item is browsable.

Returns
boolean

See also:

isPlayable

public boolean isPlayable ()

Returns whether this item is playable.

Returns
boolean

See also:

setMetadata

public void setMetadata (MediaMetadata2 metadata)

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

toString

public String toString ()

Returns
String