public class

MediaItem.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media2.common.MediaItem.Builder

Subclasses:

CallbackMediaItem.Builder, UriMediaItem.Builder, FileMediaItem.Builder

Overview

Builder for MediaItem.

Summary

Constructors
publicBuilder()

Default constructor

Methods
public MediaItembuild()

Build MediaItem.

public MediaItem.BuildersetEndPosition(long position)

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

public MediaItem.BuildersetMetadata(MediaMetadata metadata)

Set the metadata of this instance.

public MediaItem.BuildersetStartPosition(long position)

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

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Default constructor

Methods

public MediaItem.Builder setMetadata(MediaMetadata metadata)

Set the metadata of this instance. null for unset.

Parameters:

metadata: metadata

Returns:

this instance for chaining

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: the start position in milliseconds at which the playback will start

Returns:

this instance for chaining

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: the end position in milliseconds at which the playback will end

Returns:

this instance for chaining

public MediaItem build()

Build MediaItem.

Returns:

a new MediaItem.