Builder

class Builder
kotlin.Any
   ↳ androidx.media2.MediaItem2.Builder

Builder for MediaItem2

Summary

Public constructors
<init>(flags: Int)

Constructor for Builder

Public methods
MediaItem2.Builder
setMediaId(@Nullable mediaId: String?)

Set the media id of this instance.

MediaItem2.Builder
setDataSourceDesc(@Nullable dataSourceDesc: DataSourceDesc2?)

Set the data source descriptor for this instance.

MediaItem2.Builder
setMetadata(@Nullable metadata: MediaMetadata2?)

Set the metadata of this instance.

MediaItem2

Build MediaItem2.

Public constructors

<init>

Builder(flags: Int)

Constructor for Builder

Parameters
flags Int:

Public methods

setMediaId

@NonNull fun setMediaId(@Nullable mediaId: String?): MediaItem2.Builder

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

If used, this should be a persistent unique key for the underlying content so session and controller can uniquely identify a media content.

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.

Parameters
mediaId String?: media id
Return
MediaItem2.Builder: this instance for chaining

setDataSourceDesc

@NonNull fun setDataSourceDesc(@Nullable dataSourceDesc: DataSourceDesc2?): MediaItem2.Builder

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

Parameters
dataSourceDesc DataSourceDesc2?: data source descriptor
Return
MediaItem2.Builder: this instance for chaining

setMetadata

@NonNull fun setMetadata(@Nullable metadata: MediaMetadata2?): MediaItem2.Builder

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.

Parameters
metadata MediaMetadata2?: metadata
Return
MediaItem2.Builder: this instance for chaining

build

@NonNull fun build(): MediaItem2

Build MediaItem2.

Return
MediaItem2: a new MediaItem2.