belongs to Maven artifact androidx.media:media:1.0.0-alpha1

DataSourceDesc.Builder

public static class DataSourceDesc.Builder
extends Object

java.lang.Object
   ↳ androidx.media.DataSourceDesc.Builder


Builder class for DataSourceDesc objects.

Summary

Public constructors

DataSourceDesc.Builder()

Constructs a new Builder with the defaults.

DataSourceDesc.Builder(DataSourceDesc dsd)

Constructs a new Builder from a given DataSourceDesc instance

Public methods

DataSourceDesc build()

Combines all of the fields that have been set and return a new DataSourceDesc object.

DataSourceDesc.Builder setDataSource(Media2DataSource m2ds)

Sets the data source (Media2DataSource) to use.

DataSourceDesc.Builder setDataSource(FileDescriptor fd)

Sets the data source (FileDescriptor) to use.

DataSourceDesc.Builder setDataSource(FileDescriptor fd, long offset, long length)

Sets the data source (FileDescriptor) to use.

DataSourceDesc.Builder setDataSource(Context context, Uri uri, Map<String, String> headers, List<HttpCookie> cookies)

Sets the data source as a content Uri.

DataSourceDesc.Builder setDataSource(Context context, Uri uri)

Sets the data source as a content Uri.

DataSourceDesc.Builder setEndPosition(long position)

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

DataSourceDesc.Builder setMediaId(String mediaId)

Sets the media Id of this data source.

DataSourceDesc.Builder setStartPosition(long position)

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

Inherited methods

Public constructors

DataSourceDesc.Builder

DataSourceDesc.Builder ()

Constructs a new Builder with the defaults.

DataSourceDesc.Builder

DataSourceDesc.Builder (DataSourceDesc dsd)

Constructs a new Builder from a given DataSourceDesc instance

Parameters
dsd DataSourceDesc: the DataSourceDesc object whose data will be reused in the new Builder.

Public methods

build

DataSourceDesc build ()

Combines all of the fields that have been set and return a new DataSourceDesc object. IllegalStateException will be thrown if there is conflict between fields.

Returns
DataSourceDesc a new DataSourceDesc object

setDataSource

DataSourceDesc.Builder setDataSource (Media2DataSource m2ds)

Sets the data source (Media2DataSource) to use.

Parameters
m2ds Media2DataSource: the Media2DataSource for the media you want to play

Returns
DataSourceDesc.Builder the same Builder instance.

Throws
NullPointerException if m2ds is null.

setDataSource

DataSourceDesc.Builder setDataSource (FileDescriptor fd)

Sets the data source (FileDescriptor) to use. The FileDescriptor must be seekable (N.B. a LocalSocket is not seekable). It is the caller's responsibility to close the file descriptor after the source has been used.

Parameters
fd FileDescriptor: the FileDescriptor for the file you want to play

Returns
DataSourceDesc.Builder the same Builder instance.

Throws
NullPointerException if fd is null.

setDataSource

DataSourceDesc.Builder setDataSource (FileDescriptor fd, 
                long offset, 
                long length)

Sets the data source (FileDescriptor) to use. The FileDescriptor must be seekable (N.B. a LocalSocket is not seekable). It is the caller's responsibility to close the file descriptor after the source has been used. Any negative number for offset is treated as 0. Any negative number for length is treated as maximum length of the data source.

Parameters
fd FileDescriptor: the FileDescriptor for the file you want to play

offset long: the offset into the file where the data to be played starts, in bytes

length long: the length in bytes of the data to be played

Returns
DataSourceDesc.Builder the same Builder instance.

Throws
NullPointerException if fd is null.

setDataSource

DataSourceDesc.Builder setDataSource (Context context, 
                Uri uri, 
                Map<String, String> headers, 
                List<HttpCookie> cookies)

Sets the data source as a content Uri. To provide cookies for the subsequent HTTP requests, you can install your own default cookie handler and use other variants of setDataSource 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
context Context: the Context to use when resolving the Uri

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

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

cookies List: the cookies to be sent together with the request

Returns
DataSourceDesc.Builder the same Builder instance.

Throws
NullPointerException if context or uri is null.
IllegalArgumentException if the cookie handler is not of CookieManager type when cookies are provided.

setDataSource

DataSourceDesc.Builder setDataSource (Context context, 
                Uri uri)

Sets the data source as a content Uri.

Parameters
context Context: the Context to use when resolving the Uri

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

Returns
DataSourceDesc.Builder the same Builder instance.

Throws
NullPointerException if context or uri is null.

setEndPosition

DataSourceDesc.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 data source.

Parameters
position long: the end position in milliseconds at which the playback will end

Returns
DataSourceDesc.Builder the same Builder instance.

setMediaId

DataSourceDesc.Builder setMediaId (String mediaId)

Sets the media Id of this data source.

Parameters
mediaId String: the media Id of this data source

Returns
DataSourceDesc.Builder the same Builder instance.

setStartPosition

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

Returns
DataSourceDesc.Builder the same Builder instance.