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

## Class BaseMediaChunkIterator

- java.lang.Object
- - com.google.android.exoplayer2.source.chunk.BaseMediaChunkIterator

- All Implemented Interfaces:
    `MediaChunkIterator`
  Direct Known Subclasses:
    `DefaultDashChunkSource.RepresentationSegmentIterator`, `FakeAdaptiveDataSet.Iterator`, `FakeMediaChunkIterator`

      public abstract class BaseMediaChunkIterator
      extends Object
      implements MediaChunkIterator

  Base class for `MediaChunkIterator`s. Handles `next()` and `isEnded()`, and provides a bounds check for child classes.

- - ### Field Summary

    - ### Fields inherited from interface com.google.android.exoplayer2.source.chunk.MediaChunkIterator

      `EMPTY`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `BaseMediaChunkIterator​(long fromIndex, long toIndex)` | Creates base iterator.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `checkInBounds()` | Verifies that the iterator points to a valid element.
    `protected long` | `getCurrentIndex()` | Returns the current index this iterator is pointing to.
    `boolean` | `isEnded()` | Returns whether the iteration has reached the end of the available data.
    `boolean` | `next()` | Moves the iterator to the next media chunk.
    `void` | `reset()` | Resets the iterator to the initial position.

    - ### Methods inherited from class java.lang.Object

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

    - ### Methods inherited from interface com.google.android.exoplayer2.source.chunk.MediaChunkIterator

      `getChunkEndTimeUs, getChunkStartTimeUs, getDataSpec`

- - ### Constructor Detail

    - #### BaseMediaChunkIterator

          public BaseMediaChunkIterator​(long fromIndex,
                                        long toIndex)

      Creates base iterator.
      Parameters:
        `fromIndex` - The first available index.
        `toIndex` - The last available index.

  - ### Method Detail

    - #### isEnded

          public boolean isEnded()

      Description copied from interface: `MediaChunkIterator`
      Returns whether the iteration has reached the end of the available data.
      Specified by:
        `isEnded` in interface `MediaChunkIterator`

    - #### next

          public boolean next()

      Description copied from interface: `MediaChunkIterator`
      Moves the iterator to the next media chunk.

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

      Specified by:
        `next` in interface `MediaChunkIterator`
      Returns:
        Whether the iterator points to a media chunk with available data.

    - #### reset

          public void reset()

      Description copied from interface: `MediaChunkIterator`
      Resets the iterator to the initial position.
      Specified by:
        `reset` in interface `MediaChunkIterator`

    - #### checkInBounds

          protected final void checkInBounds()

      Verifies that the iterator points to a valid element.
      Throws:
        `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.