DataSource
interface DataSource : DataReader
AesCipherDataSource |
A |
BaseDataSource |
Base |
CacheDataSource |
A |
DefaultDataSource |
A |
HttpDataSource |
An HTTP |
PlaceholderDataSource |
A DataSource which provides no data. |
PriorityDataSource |
A |
ResolvingDataSource |
|
StatsDataSource |
|
TeeDataSource |
Tees data into a |
AssetDataSource |
A |
ByteArrayDataSource |
A |
ContentDataSource |
A |
CronetDataSource |
DataSource without intermediate buffer based on Cronet API set using UrlRequest. |
DataSchemeDataSource |
A |
DefaultHttpDataSource |
An |
FakeDataSource |
A fake |
FileDataSource |
A |
FileDescriptorDataSource |
A |
HttpEngineDataSource |
DataSource without intermediate buffer based on |
KtorDataSource |
An |
MediaDataSourceAdapter |
A |
OkHttpDataSource |
An |
RawResourceDataSource |
A |
RtmpDataSource |
A Real-Time Messaging Protocol (RTMP) |
UdpDataSource |
A UDP |
Reads data from URI-identified resources.
Summary
Nested types |
|---|
interface DataSource.FactoryA factory for |
Public functions |
|
|---|---|
Unit |
@UnstableApiAdds a |
Unit |
Closes the source. |
(Mutable)Map<String!, (Mutable)List<String!>!>! |
When the source is open, returns the response headers associated with the last |
Uri? |
When the source is open, returns the |
Long |
@UnstableApiOpens the source to read the specified data. |
Inherited functions |
|---|
Public functions
addTransferListener
@UnstableApi
fun addTransferListener(transferListener: TransferListener!): Unit
Adds a TransferListener to listen to data transfers. This method is not thread-safe.
| Parameters | |
|---|---|
transferListener: TransferListener! |
close
@UnstableApi
fun close(): Unit
Closes the source. This method must be called even if the corresponding call to open threw an IOException.
| Throws | |
|---|---|
java.io.IOException |
If an error occurs closing the source. |
getResponseHeaders
@UnstableApi
fun getResponseHeaders(): (Mutable)Map<String!, (Mutable)List<String!>!>!
When the source is open, returns the response headers associated with the last open call. Otherwise, returns an empty map.
Key look-up in the returned map is case-insensitive.
getUri
@UnstableApi
fun getUri(): Uri?
When the source is open, returns the Uri from which data is being read. The returned Uri will be identical to the one passed open in the DataSpec unless redirection has occurred. If redirection has occurred, the Uri after redirection is returned.
open
@UnstableApi
fun open(dataSpec: DataSpec!): Long
Opens the source to read the specified data. If an IOException is thrown, callers must still call close to ensure that any partial effects of the invocation are cleaned up.
The following edge case behaviors apply:
- If the
requested positionis within the resource, but therequested lengthextends beyond the end of the resource, thenopenwill succeed and data from the requested position to the end of the resource will be made available throughread. - If the
requested positionis equal to the length of the resource, thenopenwill succeed, andreadwill immediately returnRESULT_END_OF_INPUT. - If the
requested positionis greater than the length of the resource, thenopenwill throw anIOExceptionfor whichisCausedByPositionOutOfRangewill betrue.
| Parameters | |
|---|---|
dataSpec: DataSpec! |
Defines the data to be read. |
| Returns | |
|---|---|
Long |
The number of bytes that can be read from the opened source. For unbounded requests (i.e., requests where |
| Throws | |
|---|---|
java.io.IOException |
If an error occurs opening the source. |