MediaItem.Builder

Added in 1.0.0
Deprecated in 1.3.0

public class MediaItem.Builder

Known direct subclasses
CallbackMediaItem.Builder

This class is deprecated.

androidx.media2 is deprecated.

FileMediaItem.Builder

This class is deprecated.

androidx.media2 is deprecated.

UriMediaItem.Builder

This class is deprecated.

androidx.media2 is deprecated.


Builder for MediaItem.

Summary

Public constructors

Default constructor

Public methods

@NonNull MediaItem

Build MediaItem.

@NonNull MediaItem.Builder
setEndPosition(long position)

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

@NonNull MediaItem.Builder

Set the metadata of this instance.

@NonNull MediaItem.Builder
setStartPosition(long position)

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

Public constructors

Builder

Added in 1.0.0
Deprecated in 1.3.0
public Builder()

Default constructor

Public methods

build

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaItem build()

Build MediaItem.

Returns
@NonNull MediaItem

a new MediaItem.

setEndPosition

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull 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
long position

the end position in milliseconds at which the playback will end

Returns
@NonNull MediaItem.Builder

this instance for chaining

setMetadata

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull MediaItem.Builder setMetadata(@Nullable MediaMetadata metadata)

Set the metadata of this instance. null for unset.

Parameters
@Nullable MediaMetadata metadata

metadata

Returns
@NonNull MediaItem.Builder

this instance for chaining

setStartPosition

Added in 1.0.0
Deprecated in 1.3.0
public @NonNull 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
long position

the start position in milliseconds at which the playback will start

Returns
@NonNull MediaItem.Builder

this instance for chaining