FileDataSourceDesc.Builder
public
static
class
FileDataSourceDesc.Builder
extends BuilderBase<FileDataSourceDesc.Builder>
| java.lang.Object | ||
| ↳ | android.media.DataSourceDesc.BuilderBase<android.media.FileDataSourceDesc.Builder> | |
| ↳ | android.media.FileDataSourceDesc.Builder | |
Builder class for FileDataSourceDesc objects.
Here is an example where Builder is used to define the
FileDataSourceDesc to be used by a MediaPlayer2 instance:
FileDataSourceDesc newDSD = new FileDataSourceDesc.Builder()
.setDataSource(pfd, 0, srcLength)
.setStartPosition(1000)
.setEndPosition(15000)
.build();
mediaplayer2.setDataSourceDesc(newDSD);
Summary
Public constructors | |
|---|---|
FileDataSourceDesc.Builder()
Constructs a new Builder with the defaults. |
|
FileDataSourceDesc.Builder(FileDataSourceDesc dsd)
Constructs a new Builder from a given |
|
Public methods | |
|---|---|
FileDataSourceDesc
|
build()
Combines all of the fields that have been set and return a new
|
FileDataSourceDesc.Builder
|
setDataSource(ParcelFileDescriptor pfd, long offset, long length)
Sets the data source (ParcelFileDescriptor) to use. |
FileDataSourceDesc.Builder
|
setDataSource(ParcelFileDescriptor pfd)
Sets the data source (ParcelFileDescriptor) to use. |
Inherited methods | |
|---|---|
Public constructors
FileDataSourceDesc.Builder
public FileDataSourceDesc.Builder ()
Constructs a new Builder with the defaults.
FileDataSourceDesc.Builder
public FileDataSourceDesc.Builder (FileDataSourceDesc dsd)
Constructs a new Builder from a given FileDataSourceDesc instance
| Parameters | |
|---|---|
dsd |
FileDataSourceDesc: the FileDataSourceDesc object whose data will be reused
in the new Builder. |
Public methods
build
public FileDataSourceDesc build ()
Combines all of the fields that have been set and return a new
FileDataSourceDesc object. IllegalStateException will be
thrown if there is conflict between fields.
| Returns | |
|---|---|
FileDataSourceDesc |
a new FileDataSourceDesc object
This value will never be null. |
setDataSource
public FileDataSourceDesc.Builder setDataSource (ParcelFileDescriptor pfd, long offset, long length)
Sets the data source (ParcelFileDescriptor) to use. The ParcelFileDescriptor must be
seekable (N.B. a LocalSocket is not seekable). When the FileDataSourceDesc
created by this builder is passed to MediaPlayer2 via
MediaPlayer2#setDataSource,
MediaPlayer2#setNextDataSource or
MediaPlayer2#setNextDataSources, MediaPlayer2 will
close the ParcelFileDescriptor.
Any negative number for offset is treated as 0.
Any negative number for length is treated as maximum length of the data source.
| Parameters | |
|---|---|
pfd |
ParcelFileDescriptor: the ParcelFileDescriptor for the file to play
This value must never be null. |
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 | |
|---|---|
FileDataSourceDesc.Builder |
the same Builder instance. |
| Throws | |
|---|---|
NullPointerException |
if pfd is null. |
setDataSource
public FileDataSourceDesc.Builder setDataSource (ParcelFileDescriptor pfd)
Sets the data source (ParcelFileDescriptor) to use. The ParcelFileDescriptor must be
seekable (N.B. a LocalSocket is not seekable). When the FileDataSourceDesc
created by this builder is passed to MediaPlayer2 via
MediaPlayer2#setDataSource,
MediaPlayer2#setNextDataSource or
MediaPlayer2#setNextDataSources, MediaPlayer2 will
close the ParcelFileDescriptor.
| Parameters | |
|---|---|
pfd |
ParcelFileDescriptor: the ParcelFileDescriptor for the file to play
This value must never be null. |
| Returns | |
|---|---|
FileDataSourceDesc.Builder |
the same Builder instance. |
| Throws | |
|---|---|
NullPointerException |
if pfd is null. |