public final class

UriMediaItem.Builder

extends MediaItem.Builder

 java.lang.Object

androidx.media2.common.MediaItem.Builder

↳androidx.media2.common.UriMediaItem.Builder

Overview

This Builder class simplifies the creation of a UriMediaItem object.

Summary

Constructors
publicBuilder(Uri uri)

Creates a new Builder object with a content Uri.

publicBuilder(Uri uri, java.util.Map<java.lang.String, java.lang.String> headers, java.util.List<java.net.HttpCookie> cookies)

Creates a new Builder object with a content Uri.

Methods
public UriMediaItembuild()

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(Uri uri)

Creates a new Builder object with a content Uri.

Parameters:

uri: the Content URI of the data you want to play

public Builder(Uri uri, java.util.Map<java.lang.String, java.lang.String> headers, java.util.List<java.net.HttpCookie> cookies)

Creates a new Builder object with a content Uri. To provide cookies for the subsequent HTTP requests, you can install your own default cookie handler and use other variants of setMediaItem APIs instead.

Note that the cross domain redirection is allowed by default, but that can be changed with key/value pairs through the headers parameter with "android-allow-cross-domain-redirect" as the key and "0" or "1" as the value to disallow or allow cross domain redirection.

Parameters:

uri: the Content URI of the data you want to play
headers: the headers to be sent together with the request for the data The headers must not include cookies. Instead, use the cookies param.
cookies: the cookies to be sent together with the request

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 UriMediaItem build()

Returns:

A new UriMediaItem with values supplied by the Builder.