public final class MediaItem


Representation of a media item.

Summary

Nested types

public final class MediaItem.AdsConfiguration

Configuration for playing back linear ads with a media item.

Builder for AdsConfiguration instances.

public final class MediaItem.Builder

A builder for MediaItem instances.

Optionally clips the media item to a custom start and end position.

Builder for ClippingConfiguration instances.

This class is deprecated.

Use ClippingConfiguration instead.

public final class MediaItem.DrmConfiguration

DRM configuration for a media item.

Builder for DrmConfiguration.

public final class MediaItem.LiveConfiguration

Live playback configuration.

Builder for LiveConfiguration instances.

public final class MediaItem.LocalConfiguration

Properties for local playback.

public final class MediaItem.RequestMetadata

Metadata that helps the player to understand a playback request represented by a .

Builder for RequestMetadata instances.

This class is deprecated.

Use MediaItem.SubtitleConfiguration instead

Properties for a text track.

Builder for SubtitleConfiguration instances.

Constants

static final String

The default media ID that is used if the media ID is not explicitly set by setMediaId.

static final MediaItem

Empty MediaItem.

Public fields

final MediaItem.ClippingConfiguration

The clipping properties.

final MediaItem.ClippingProperties

This field is deprecated.

Use clippingConfiguration instead.

final MediaItem.LiveConfiguration

The live playback configuration.

final @Nullable MediaItem.LocalConfiguration

Optional configuration for local playback.

final String

Identifies the media item.

final MediaMetadata

The media metadata.

final @Nullable MediaItem.LocalConfiguration

This field is deprecated.

Use localConfiguration instead.

final MediaItem.RequestMetadata

The media RequestMetadata.

Public methods

MediaItem.Builder

Returns a Builder initialized with the values of this instance.

boolean
static MediaItem

Restores a MediaItem from a Bundle.

static MediaItem

Creates a MediaItem for the given URI.

static MediaItem
fromUri(Uri uri)

Creates a MediaItem for the given URI.

int
Bundle

Returns a Bundle representing the information stored in this object.

Bundle

Returns a Bundle representing the information stored in this MediaItem object, while including the localConfiguration field if it is not null (otherwise skips it).

Constants

DEFAULT_MEDIA_ID

public static final String DEFAULT_MEDIA_ID = ""

The default media ID that is used if the media ID is not explicitly set by setMediaId.

EMPTY

public static final MediaItem EMPTY

Empty MediaItem.

Public fields

clippingConfiguration

public final MediaItem.ClippingConfiguration clippingConfiguration

The clipping properties.

clippingProperties

@UnstableApi
public final MediaItem.ClippingProperties clippingProperties

liveConfiguration

public final MediaItem.LiveConfiguration liveConfiguration

The live playback configuration.

localConfiguration

public final @Nullable MediaItem.LocalConfiguration localConfiguration

Optional configuration for local playback. May be null if shared over process boundaries.

mediaId

public final String mediaId

Identifies the media item.

mediaMetadata

public final MediaMetadata mediaMetadata

The media metadata.

playbackProperties

@UnstableApi
public final @Nullable MediaItem.LocalConfiguration playbackProperties

requestMetadata

public final MediaItem.RequestMetadata requestMetadata

The media RequestMetadata.

Public methods

buildUpon

public MediaItem.Builder buildUpon()

Returns a Builder initialized with the values of this instance.

equals

public boolean equals(@Nullable Object obj)

fromBundle

@UnstableApi
public static MediaItem fromBundle(Bundle bundle)

Restores a MediaItem from a Bundle.

The localConfiguration of a restored instance will always be null.

fromUri

public static MediaItem fromUri(String uri)

Creates a MediaItem for the given URI.

Parameters
String uri

The URI.

Returns
MediaItem

An MediaItem for the given URI.

fromUri

public static MediaItem fromUri(Uri uri)

Creates a MediaItem for the given URI.

Parameters
Uri uri

The uri.

Returns
MediaItem

An MediaItem for the given URI.

hashCode

public int hashCode()

toBundle

@UnstableApi
public Bundle toBundle()

Returns a Bundle representing the information stored in this object.

It omits the localConfiguration field. The localConfiguration of an instance restored from such a bundle by fromBundle will be null.

toBundleIncludeLocalConfiguration

@UnstableApi
public Bundle toBundleIncludeLocalConfiguration()

Returns a Bundle representing the information stored in this MediaItem object, while including the localConfiguration field if it is not null (otherwise skips it).