@UnstableApi
interface DataReader

Known direct subclasses
DataSource

Reads data from URI-identified resources.

ExtractorInput

Provides data to be consumed by an Extractor.

Known indirect subclasses
AesCipherDataSource

A DataSource that decrypts the data read from an upstream source.

AssetDataSource

A DataSource for reading from a local asset.

BaseDataSource

Base DataSource implementation to keep a list of TransferListeners.

ByteArrayDataSource

A DataSource for reading from a byte array.

CacheDataSource

A DataSource that reads and writes a Cache.

ContentDataSource

A DataSource for reading from a content URI.

CronetDataSource

DataSource without intermediate buffer based on Cronet API set using UrlRequest.

DataSchemeDataSource

A DataSource for reading data URLs, as defined by RFC 2397.

DefaultDataSource

A DataSource that supports multiple URI schemes.

DefaultExtractorInput

An ExtractorInput that wraps a DataReader.

DefaultHttpDataSource

An HttpDataSource that uses Android's HttpURLConnection.

FakeDataSource

A fake DataSource capable of simulating various scenarios.

FakeExtractorInput

A fake ExtractorInput capable of simulating various scenarios.

FileDataSource

A DataSource for reading local files.

FileDescriptorDataSource

A DataSource for reading from a FileDescriptor.

ForwardingExtractorInput

An overridable ExtractorInput implementation forwarding all methods to another input.

HttpDataSource

An HTTP DataSource.

HttpEngineDataSource

DataSource without intermediate buffer based on HttpEngine set using UrlRequest.

MediaDataSourceAdapter

A DataSource for reading from a MediaDataSource.

OkHttpDataSource

An HttpDataSource that delegates to Square's Call.Factory.

PlaceholderDataSource

A DataSource which provides no data.

PriorityDataSource

A DataSource that can be used as part of a task registered with a .

RawResourceDataSource

A DataSource for reading a raw resource.

ResolvingDataSource

DataSource wrapper allowing just-in-time resolution of DataSpecs.

RtmpDataSource

A Real-Time Messaging Protocol (RTMP) DataSource.

StatsDataSource

DataSource wrapper which keeps track of bytes transferred, redirected uris, and response headers.

TeeDataSource

Tees data into a DataSink as the data is read.

UdpDataSource

A UDP DataSource.


Reads bytes from a data stream.

Summary

Public functions

Int
read(buffer: ByteArray!, offset: Int, length: Int)

Reads up to length bytes of data from the input.

Public functions

read

fun read(buffer: ByteArray!, offset: Int, length: Int): Int

Reads up to length bytes of data from the input.

If readLength is zero then 0 is returned. Otherwise, if no data is available because the end of the opened range has been reached, then RESULT_END_OF_INPUT is returned. Otherwise, the call will block until at least one byte of data has been read and the number of bytes read is returned.

Parameters
buffer: ByteArray!

A target array into which data should be written.

offset: Int

The offset into the target array at which to write.

length: Int

The maximum number of bytes to read from the input.

Returns
Int

The number of bytes read, or RESULT_END_OF_INPUT if the input has ended. This may be less than length because the end of the input (or available data) was reached, the method was interrupted, or the operation was aborted early for another reason.

Throws
java.io.IOException

If an error occurs reading from the input.