Back to Exoplayer

DataChunk (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/source/chunk/DataChunk.html

latest6.8 KB
Original Source

Package com.google.android.exoplayer2.source.chunk

Class DataChunk


[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public abstract classDataChunkextends[Chunk](Chunk.html "class in com.google.android.exoplayer2.source.chunk")

Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.

A base class for Chunk implementations where the data should be loaded into a byte[] before being consumed.

Field Summary

- 

Fields inherited from class com.google.android.exoplayer2.source.chunk.Chunk

dataSource, dataSpec, endTimeUs, loadTaskId, startTimeUs, trackFormat, trackSelectionData, trackSelectionReason, type

Constructor Summary

Constructors | Constructor | Description | | --- | --- | | DataChunk​(DataSource dataSource, DataSpec dataSpec, @com.google.android.exoplayer2.C.DataType int type, Format trackFormat, @com.google.android.exoplayer2.C.SelectionReason int trackSelectionReason, Object trackSelectionData, byte[] data) | Deprecated. |

Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description | | --- | --- | --- | | void | cancelLoad() | Deprecated.

Cancels the load. | | protected abstract void | consume​(byte[] data, int limit) | Deprecated.

Called by load(). | | byte[] | getDataHolder() | Deprecated.

Returns the array in which the data is held. | | void | load() | Deprecated.

Performs the load, returning on completion or cancellation. |

- 

Methods inherited from class com.google.android.exoplayer2.source.chunk.Chunk

bytesLoaded, getDurationUs, getResponseHeaders, getUri

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

- 

DataChunk

public DataChunk​([DataSource](../../upstream/DataSource.html "interface in com.google.android.exoplayer2.upstream")dataSource,[DataSpec](../../upstream/DataSpec.html "class in com.google.android.exoplayer2.upstream")dataSpec,
                 @com.google.android.exoplayer2.C.DataType int type,[Format](../../Format.html "class in com.google.android.exoplayer2")trackFormat,
                 @com.google.android.exoplayer2.C.SelectionReason int trackSelectionReason,
                 @Nullable[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")trackSelectionData,
                 @Nullable
                 byte[] data)

Deprecated. Parameters:dataSource - The source from which the data should be loaded.dataSpec - Defines the data to be loaded.type - See Chunk.type.trackFormat - See Chunk.trackFormat.trackSelectionReason - See Chunk.trackSelectionReason.trackSelectionData - See Chunk.trackSelectionData.data - An optional recycled array that can be used as a holder for the data.

Method Detail

- 

getDataHolder

public byte[] getDataHolder()

Deprecated.

Returns the array in which the data is held.

This method should be used for recycling the holder only, and not for reading the data.

Returns:The array in which the data is held.

- 

cancelLoad

public final void cancelLoad()

Deprecated.

Description copied from interface: Loader.Loadable

Cancels the load.

Loadable implementations should ensure that a currently executing Loader.Loadable.load() call will exit reasonably quickly after this method is called. The Loader.Loadable.load() call may exit either by returning or by throwing an IOException.

If there is a currently executing Loader.Loadable.load() call, then the thread on which that call is being made will be interrupted immediately after the call to this method. Hence implementations do not need to (and should not attempt to) interrupt the loading thread themselves.

Although the loading thread will be interrupted, Loadable implementations should not use the interrupted status of the loading thread in Loader.Loadable.load() to determine whether the load has been canceled. This approach is not robust [Internal ref: b/79223737]. Instead, implementations should use their own flag to signal cancelation (for example, using AtomicBoolean).

- 

load

public final void load()
                throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Deprecated.

Description copied from interface: Loader.Loadable

Performs the load, returning on completion or cancellation. Throws:IOException - If the input could not be loaded.

- 

consume

protected abstract void consume​(byte[] data,
                                int limit)
                         throws[IOException](https://developer.android.com/reference/java/io/IOException.html "class or interface in java.io")

Deprecated.

Called by load(). Implementations should override this method to consume the loaded data. Parameters:data - An array containing the data.limit - The limit of the data.Throws:IOException - If an error occurs consuming the loaded data.