UriMediaItem.Builder

Added in 1.0.0
Deprecated in 1.3.0

class UriMediaItem.Builder : MediaItem.Builder


This Builder class simplifies the creation of a UriMediaItem object.

Summary

Public constructors

Builder(uri: Uri)

Creates a new Builder object with a content Uri.

Builder(
    uri: Uri,
    headers: (Mutable)Map<String!, String!>?,
    cookies: (Mutable)List<HttpCookie!>?
)

Creates a new Builder object with a content Uri.

Public functions

UriMediaItem
UriMediaItem.Builder
setEndPosition(position: Long)

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

UriMediaItem.Builder

Set the metadata of this instance.

UriMediaItem.Builder

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

Creates a new Builder object with a content Uri.

Parameters
uri: Uri

the Content URI of the data you want to play

Builder

Added in 1.0.0
Deprecated in 1.3.0
Builder(
    uri: Uri,
    headers: (Mutable)Map<String!, String!>?,
    cookies: (Mutable)List<HttpCookie!>?
)

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: Uri

the Content URI of the data you want to play

headers: (Mutable)Map<String!, String!>?

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

cookies: (Mutable)List<HttpCookie!>?

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 functions

build

Added in 1.3.0
Deprecated in 1.3.0
fun build(): UriMediaItem
Returns
UriMediaItem

A new UriMediaItem with values supplied by the Builder.

setEndPosition

Added in 1.3.0
Deprecated in 1.3.0
fun setEndPosition(position: Long): UriMediaItem.Builder

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
UriMediaItem.Builder

this instance for chaining

setMetadata

Added in 1.3.0
Deprecated in 1.3.0
fun setMetadata(metadata: MediaMetadata?): UriMediaItem.Builder

Set the metadata of this instance. null for unset.

Parameters
metadata: MediaMetadata?

metadata

Returns
UriMediaItem.Builder

this instance for chaining

setStartPosition

Added in 1.3.0
Deprecated in 1.3.0
fun setStartPosition(position: Long): UriMediaItem.Builder

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
UriMediaItem.Builder

this instance for chaining