Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Builder

open class Builder
kotlin.Any
   ↳ androidx.media2.common.MediaItem.Builder

Builder for MediaItem.

Summary

Public constructors

Default constructor

Public methods

open MediaItem

Build MediaItem.

open MediaItem.Builder
setEndPosition(position: Long)

Sets the end position in milliseconds at which the playback will end.

open MediaItem.Builder
setMetadata(@Nullable metadata: MediaMetadata?)

Set the metadata of this instance.

open MediaItem.Builder

Sets the start position in milliseconds at which the playback will start.

Public constructors

<init>

Builder()

Default constructor

Public methods

build

@NonNull open fun build(): MediaItem

Build MediaItem.

Return
MediaItem: a new MediaItem.

setEndPosition

@NonNull open fun setEndPosition(position: Long): MediaItem.Builder

Sets the end position in milliseconds at which the playback will end. Any negative number is treated as maximum length of the media item.

Parameters
position Long: the end position in milliseconds at which the playback will end
Return
MediaItem.Builder: this instance for chaining

setMetadata

@NonNull open fun setMetadata(@Nullable metadata: MediaMetadata?): MediaItem.Builder

Set the metadata of this instance. null for unset.

Parameters
metadata MediaMetadata?: metadata
Return
MediaItem.Builder: this instance for chaining

setStartPosition

@NonNull open fun setStartPosition(position: Long): MediaItem.Builder

Sets the start position in milliseconds at which the playback will start. Any negative number is treated as 0.

Parameters
position Long: the start position in milliseconds at which the playback will start
Return
MediaItem.Builder: this instance for chaining