@UnstableApi
abstract class BaseDataSource : DataSource

Known direct subclasses
AssetDataSource

A DataSource for reading from a local asset.

ByteArrayDataSource

A DataSource for reading from a byte array.

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.

DefaultHttpDataSource

An HttpDataSource that uses Android's HttpURLConnection.

FakeDataSource

A fake DataSource capable of simulating various scenarios.

FileDataSource

A DataSource for reading local files.

FileDescriptorDataSource

A DataSource for reading from a FileDescriptor.

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.

RawResourceDataSource

A DataSource for reading a raw resource.

RtmpDataSource

A Real-Time Messaging Protocol (RTMP) DataSource.

UdpDataSource

A UDP DataSource.


Base DataSource implementation to keep a list of TransferListeners.

Subclasses must call transferInitializing, transferStarted, bytesTransferred, and transferEnded to inform listeners of data transfers.

Summary

Protected constructors

BaseDataSource(isNetwork: Boolean)

Creates base data source.

Public functions

Unit

Adds a TransferListener to listen to data transfers.

Protected functions

Unit
bytesTransferred(bytesTransferred: Int)

Notifies listeners that bytes were transferred.

Unit

Notifies listeners that a transfer ended.

Unit

Notifies listeners that data transfer for the specified DataSpec is being initialized.

Unit

Notifies listeners that data transfer for the specified DataSpec started.

Inherited functions

From androidx.media3.common.DataReader
abstract Int
read(buffer: ByteArray!, offset: Int, length: Int)

Reads up to length bytes of data from the input.

From androidx.media3.datasource.DataSource
abstract Unit

Closes the source.

(Mutable)Map<String!, (Mutable)List<String!>!>!

When the source is open, returns the response headers associated with the last open call.

abstract Uri?

When the source is open, returns the Uri from which data is being read.

abstract Long

Opens the source to read the specified data.

Protected constructors

BaseDataSource

protected BaseDataSource(isNetwork: Boolean)

Creates base data source.

Parameters
isNetwork: Boolean

Whether the data source loads data through a network.

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!

A TransferListener.

Protected functions

bytesTransferred

protected fun bytesTransferred(bytesTransferred: Int): Unit

Notifies listeners that bytes were transferred.

Parameters
bytesTransferred: Int

The number of bytes transferred since the previous call to this method (or if the first call, since the transfer was started).

transferEnded

protected fun transferEnded(): Unit

Notifies listeners that a transfer ended.

transferInitializing

protected fun transferInitializing(dataSpec: DataSpec!): Unit

Notifies listeners that data transfer for the specified DataSpec is being initialized.

Parameters
dataSpec: DataSpec!

DataSpec describing the data for initializing transfer.

transferStarted

protected fun transferStarted(dataSpec: DataSpec!): Unit

Notifies listeners that data transfer for the specified DataSpec started.

Parameters
dataSpec: DataSpec!

DataSpec describing the data being transferred.