MediaBrowserCompat.MediaItem


public class MediaBrowserCompat.MediaItem implements Parcelable


A class with information on a single media item for use in browsing/searching media. MediaItems are application dependent so we cannot guarantee that they contain the right values.

Summary

Constants

static final Parcelable.Creator<MediaBrowserCompat.MediaItem>
static final int

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

static final int

Flag: Indicates that the item is playable.

Public constructors

MediaItem(@NonNull MediaDescriptionCompat description, int flags)

Create a new MediaItem for use in browsing media.

Public methods

int
static MediaBrowserCompat.MediaItem

Creates an instance from a framework android.media.browse.MediaBrowser.MediaItem object.

static List<MediaBrowserCompat.MediaItem>

Creates a list of MediaItem objects from a framework android.media.browse.MediaBrowser.MediaItem object list.

@NonNull MediaDescriptionCompat

Returns the description of the media.

int

Gets the flags of the item.

@Nullable String

Returns the media id in the MediaDescriptionCompat for this item.

boolean

Returns whether this item is browsable.

boolean

Returns whether this item is playable.

@NonNull String
void
writeToParcel(Parcel out, int flags)

Inherited Constants

From android.os.Parcelable
static final int
static final int

Constants

CREATOR

Added in 1.1.0
public static final Parcelable.Creator<MediaBrowserCompat.MediaItemCREATOR

FLAG_BROWSABLE

Added in 1.1.0
public static final int FLAG_BROWSABLE = 1

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

FLAG_PLAYABLE

Added in 1.1.0
public static final int FLAG_PLAYABLE = 2

Flag: Indicates that the item is playable.

The id of this item may be passed to playFromMediaId to start playing it.

Public constructors

MediaItem

Added in 1.1.0
public MediaItem(@NonNull MediaDescriptionCompat description, int flags)

Create a new MediaItem for use in browsing media.

Parameters
@NonNull MediaDescriptionCompat description

The description of the media, which must include a media id.

int flags

The flags for this item.

Public methods

describeContents

Added in 1.1.0
public int describeContents()

fromMediaItem

Added in 1.1.0
public static MediaBrowserCompat.MediaItem fromMediaItem(Object itemObj)

Creates an instance from a framework android.media.browse.MediaBrowser.MediaItem object.

This method is only supported on API 21+. On API 20 and below, it returns null.

Parameters
Object itemObj

A android.media.browse.MediaBrowser.MediaItem object.

Returns
MediaBrowserCompat.MediaItem

An equivalent MediaItem object, or null if none.

fromMediaItemList

Added in 1.1.0
public static List<MediaBrowserCompat.MediaItemfromMediaItemList(List<Object> itemList)

Creates a list of MediaItem objects from a framework android.media.browse.MediaBrowser.MediaItem object list.

This method is only supported on API 21+. On API 20 and below, it returns null.

Parameters
List<Object> itemList

A list of android.media.browse.MediaBrowser.MediaItem objects.

Returns
List<MediaBrowserCompat.MediaItem>

An equivalent list of MediaItem objects, or null if none.

getDescription

Added in 1.1.0
public @NonNull MediaDescriptionCompat getDescription()

Returns the description of the media.

getFlags

Added in 1.1.0
public int getFlags()

Gets the flags of the item.

getMediaId

Added in 1.1.0
public @Nullable String getMediaId()

Returns the media id in the MediaDescriptionCompat for this item.

isBrowsable

Added in 1.1.0
public boolean isBrowsable()

Returns whether this item is browsable.

See also
FLAG_BROWSABLE

isPlayable

Added in 1.1.0
public boolean isPlayable()

Returns whether this item is playable.

See also
FLAG_PLAYABLE

toString

public @NonNull String toString()

writeToParcel

Added in 1.1.0
public void writeToParcel(Parcel out, int flags)