UriDataSourceDesc.Builder
public
static
class
UriDataSourceDesc.Builder
extends BuilderBase<UriDataSourceDesc.Builder>
| java.lang.Object | ||
| ↳ | android.media.DataSourceDesc.BuilderBase<android.media.UriDataSourceDesc.Builder> | |
| ↳ | android.media.UriDataSourceDesc.Builder | |
Builder class for UriDataSourceDesc objects.
Here is an example where Builder is used to define the
UriDataSourceDesc to be used by a MediaPlayer2 instance:
UriDataSourceDesc newDSD = new UriDataSourceDesc.Builder()
.setDataSource(context, uri, headers, cookies)
.setStartPosition(1000)
.setEndPosition(15000)
.build();
mediaplayer2.setDataSourceDesc(newDSD);
Summary
Public constructors | |
|---|---|
UriDataSourceDesc.Builder()
Constructs a new Builder with the defaults. |
|
UriDataSourceDesc.Builder(UriDataSourceDesc dsd)
Constructs a new Builder from a given |
|
Public methods | |
|---|---|
UriDataSourceDesc
|
build()
Combines all of the fields that have been set and return a new
|
UriDataSourceDesc.Builder
|
setDataSource(Context context, Uri uri, Map<String, String> headers, List<HttpCookie> cookies)
Sets the data source as a content Uri. |
UriDataSourceDesc.Builder
|
setDataSource(Context context, Uri uri)
Sets the data source as a content Uri. |
Inherited methods | |
|---|---|
Public constructors
UriDataSourceDesc.Builder
public UriDataSourceDesc.Builder ()
Constructs a new Builder with the defaults.
UriDataSourceDesc.Builder
public UriDataSourceDesc.Builder (UriDataSourceDesc dsd)
Constructs a new Builder from a given UriDataSourceDesc instance
| Parameters | |
|---|---|
dsd |
UriDataSourceDesc: the UriDataSourceDesc object whose data will be reused
in the new Builder. |
Public methods
build
public UriDataSourceDesc build ()
Combines all of the fields that have been set and return a new
UriDataSourceDesc object. IllegalStateException will be
thrown if there is conflict between fields.
| Returns | |
|---|---|
UriDataSourceDesc |
a new UriDataSourceDesc object
This value will never be null. |
setDataSource
public UriDataSourceDesc.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. Alternatively, you
can use this API to pass the cookies as a list of HttpCookie. If the app has not
installed a CookieHandler already, MediaPlayer2 will create a CookieManager
and populates its CookieStore with the provided cookies when this data source is passed
to MediaPlayer2. If the app has installed its own handler already, the handler
is required to be of CookieManager type such that MediaPlayer2 can update the
manager’s CookieStore.
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
This value must never be null. |
uri |
Uri: the Content URI of the data you want to play
This value must never be null. |
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.
This value may be null. |
cookies |
List: the cookies to be sent together with the request
This value may be null. |
| Returns | |
|---|---|
UriDataSourceDesc.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
public UriDataSourceDesc.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
This value must never be null. |
uri |
Uri: the Content URI of the data you want to play
This value must never be null. |
| Returns | |
|---|---|
UriDataSourceDesc.Builder |
the same Builder instance. |
| Throws | |
|---|---|
NullPointerException |
if context or uri is null. |