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

MediaItem.Builder

public static class MediaItem.Builder
extends Object

java.lang.Object
   ↳ androidx.media2.common.MediaItem.Builder


Builder for MediaItem.

Summary

Public constructors

MediaItem.Builder()

Default constructor

Public methods

MediaItem build()

Build MediaItem.

MediaItem.Builder setEndPosition(long position)

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

MediaItem.Builder setMetadata(MediaMetadata metadata)

Set the metadata of this instance.

MediaItem.Builder setStartPosition(long position)

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

Inherited methods

Public constructors

MediaItem.Builder

public MediaItem.Builder ()

Default constructor

Public methods

build

public MediaItem build ()

Build MediaItem.

Returns
MediaItem a new MediaItem.

setEndPosition

public MediaItem.Builder setEndPosition (long position)

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

Returns
MediaItem.Builder this instance for chaining

setMetadata

public MediaItem.Builder setMetadata (MediaMetadata metadata)

Set the metadata of this instance. null for unset.

Parameters
metadata MediaMetadata: metadata

Returns
MediaItem.Builder this instance for chaining

setStartPosition

public MediaItem.Builder setStartPosition (long position)

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

Returns
MediaItem.Builder this instance for chaining