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.Builder

public static final class MediaItem2.Builder
extends Object

java.lang.Object
   ↳ androidx.media.MediaItem2.Builder


Build MediaItem2

Summary

Public constructors

MediaItem2.Builder(int flags)

Constructor for MediaItem2.Builder

Public methods

MediaItem2 build()

Build MediaItem2.

MediaItem2.Builder setDataSourceDesc(DataSourceDesc dataSourceDesc)

Set the data source descriptor for this instance.

MediaItem2.Builder setMediaId(String mediaId)

Set the media id of this instance.

MediaItem2.Builder setMetadata(MediaMetadata2 metadata)

Set the metadata of this instance.

Inherited methods

Public constructors

MediaItem2.Builder

public MediaItem2.Builder (int flags)

Constructor for MediaItem2.Builder

Public methods

build

public MediaItem2 build ()

Build MediaItem2.

Returns
MediaItem2 a new MediaItem2.

setDataSourceDesc

public MediaItem2.Builder setDataSourceDesc (DataSourceDesc dataSourceDesc)

Set the data source descriptor for this instance. null for unset.

Parameters
dataSourceDesc DataSourceDesc: data source descriptor

Returns
MediaItem2.Builder this instance for chaining

setMediaId

public MediaItem2.Builder setMediaId (String mediaId)

Set the media id of this instance. null for unset.

Media id is used to identify a media contents between session and controller.

If the metadata is set with the setMetadata(MediaMetadata2) and it has media id, id from setMediaId(String) will be ignored and metadata's id will be used instead. If the id isn't set neither by setMediaId(String) nor setMetadata(MediaMetadata2), id will be automatically generated.

Parameters
mediaId String: media id

Returns
MediaItem2.Builder this instance for chaining

setMetadata

public MediaItem2.Builder setMetadata (MediaMetadata2 metadata)

Set the metadata of this instance. null for unset.

If the metadata is set with the setMetadata(MediaMetadata2) and it has media id, id from setMediaId(String) will be ignored and metadata's id will be used instead. If the id isn't set neither by setMediaId(String) nor setMetadata(MediaMetadata2), id will be automatically generated.

Parameters
metadata MediaMetadata2: metadata

Returns
MediaItem2.Builder this instance for chaining