lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

belongs to Maven artifact androidx.media:media:1.0.0-alpha3

MediaItem2

public class MediaItem2
extends Object

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

class MediaItem2.Builder

Build 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)
static MediaItem2 fromBundle(Bundle bundle)

Create a MediaItem2 from the Bundle.

DataSourceDesc getDataSourceDesc()

Return the DataSourceDesc

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.

Bundle toBundle()

Return this object as a bundle to share between processes.

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

fromBundle

public static MediaItem2 fromBundle (Bundle bundle)

Create a MediaItem2 from the Bundle.

Parameters
bundle Bundle: The bundle which was published by toBundle().

Returns
MediaItem2 The newly created MediaItem2

getDataSourceDesc

public DataSourceDesc getDataSourceDesc ()

Return the DataSourceDesc

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

Returns
DataSourceDesc 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.

Returns
String

getMetadata

public MediaMetadata2 getMetadata ()

Returns the metadata of the media.

Returns
MediaMetadata2

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

toBundle

public Bundle toBundle ()

Return this object as a bundle to share between processes.

Returns
Bundle a new bundle instance

toString

public String toString ()

Returns
String