UriMediaItem.Builder

Added in 1.0.0
Deprecated in 1.3.0

public final class UriMediaItem.Builder extends MediaItem.Builder


This Builder class simplifies the creation of a UriMediaItem object.

Summary

Public constructors

Creates a new Builder object with a content Uri.

Builder(
    @NonNull Uri uri,
    @Nullable Map<StringString> headers,
    @Nullable List<HttpCookie> cookies
)

Creates a new Builder object with a content Uri.

Public methods

@NonNull UriMediaItem
@NonNull UriMediaItem.Builder
setEndPosition(long position)

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

@NonNull UriMediaItem.Builder

Set the metadata of this instance.

@NonNull UriMediaItem.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(@NonNull Uri uri)

Creates a new Builder object with a content Uri.

Parameters
@NonNull Uri uri

the Content URI of the data you want to play

Builder

Added in 1.0.0
Deprecated in 1.3.0
public Builder(
    @NonNull Uri uri,
    @Nullable Map<StringString> headers,
    @Nullable List<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
@NonNull Uri uri

the Content URI of the data you want to play

@Nullable Map<StringString> headers

the headers to be sent together with the request for the data The headers must not include cookies. Instead, use the cookies param.

@Nullable List<HttpCookie> cookies

the cookies to be sent together with the request

Throws
java.lang.IllegalArgumentException

if the cookie handler is not of CookieManager type when cookies are provided.

Public methods

build

Added in 1.3.0
Deprecated in 1.3.0
public @NonNull UriMediaItem build()
Returns
@NonNull UriMediaItem

A new UriMediaItem with values supplied by the Builder.

setEndPosition

Added in 1.3.0
Deprecated in 1.3.0
public @NonNull UriMediaItem.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 UriMediaItem.Builder

this instance for chaining

setMetadata

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

Set the metadata of this instance. null for unset.

Parameters
@Nullable MediaMetadata metadata

metadata

Returns
@NonNull UriMediaItem.Builder

this instance for chaining

setStartPosition

Added in 1.3.0
Deprecated in 1.3.0
public @NonNull UriMediaItem.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 UriMediaItem.Builder

this instance for chaining