BaseMediaChunkIterator


@UnstableApi
public abstract class BaseMediaChunkIterator implements MediaChunkIterator


Base class for MediaChunkIterators. Handles next and isEnded, and provides a bounds check for child classes.

Summary

Protected fields

long

Public constructors

BaseMediaChunkIterator(long fromIndex, long toIndex)

Creates base iterator.

Public methods

boolean

Returns whether the iteration has reached the end of the available data.

boolean

Moves the iterator to the next media chunk.

void

Resets the iterator to the initial position.

Protected methods

final void

Verifies that the iterator points to a valid element.

final long

Returns the current index this iterator is pointing to.

Inherited Constants

From androidx.media3.exoplayer.source.chunk.MediaChunkIterator
static final MediaChunkIterator

An empty media chunk iterator without available data.

Inherited methods

From androidx.media3.exoplayer.source.chunk.MediaChunkIterator
abstract long

Returns the media end time of the chunk, in microseconds.

abstract long

Returns the media start time of the chunk, in microseconds.

abstract DataSpec

Returns the DataSpec used to load the media chunk.

Protected fields

currentIndex

protected long currentIndex

Public constructors

BaseMediaChunkIterator

public BaseMediaChunkIterator(long fromIndex, long toIndex)

Creates base iterator.

Parameters
long fromIndex

The first available index.

long toIndex

The last available index.

Public methods

isEnded

public boolean isEnded()

Returns whether the iteration has reached the end of the available data.

next

public boolean next()

Moves the iterator to the next media chunk.

Check the return value or isEnded to determine whether the iterator reached the end of the available data.

Returns
boolean

Whether the iterator points to a media chunk with available data.

reset

public void reset()

Resets the iterator to the initial position.

Protected methods

checkInBounds

protected final void checkInBounds()

Verifies that the iterator points to a valid element.

Throws
java.util.NoSuchElementException

If the iterator does not point to a valid element.

getCurrentIndex

protected final long getCurrentIndex()

Returns the current index this iterator is pointing to.