# MediaChunkIterator

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/chunk/MediaChunkIterator.java+class:androidx.media3.exoplayer.source.chunk.MediaChunkIterator)

*** ** * ** ***


```
@UnstableApi
interface MediaChunkIterator
```

<br />

Known direct subclasses [BaseMediaChunkIterator](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkIterator)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/BaseMediaChunkIterator` | Base class for `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator`s. |

Known indirect subclasses [DefaultDashChunkSource.RepresentationSegmentIterator](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DefaultDashChunkSource.RepresentationSegmentIterator), [FakeAdaptiveDataSet.Iterator](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeAdaptiveDataSet.Iterator), [FakeMediaChunkIterator](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeMediaChunkIterator)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DefaultDashChunkSource.RepresentationSegmentIterator` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator` wrapping a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/dash/DefaultDashChunkSource.RepresentationHolder`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeAdaptiveDataSet.Iterator` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator` for the chunks defined by a fake adaptive data set. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeMediaChunkIterator` | Fake `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator`. |

*** ** * ** ***

Iterator for media chunk sequences.

The iterator initially points in front of the first available element. The first call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#next()` moves the iterator to the first element. Check the return value of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#next()` or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#isEnded()` to determine whether the iterator reached the end of the available data.

## Summary

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#EMPTY()` An empty media chunk iterator without available data. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#getChunkEndTimeUs()()` Returns the media end time of the chunk, in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#getChunkStartTimeUs()()` Returns the media start time of the chunk, in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#getDataSpec()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` used to load the media chunk. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#getLocationSteeringPriorityIndex()()` Returns the index in the steering priority list of the locations (e.g., DASH service location or HLS pathway) for the current media chunks, or `Integer.MAX_VALUE` if steering is inactive or unavailable. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#isEnded()()` Returns whether the iteration has reached the end of the available data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#next()()` Moves the iterator to the next media chunk. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#reset()()` Resets the iterator to the initial position. |

## Constants

### EMPTY

```
const val EMPTY: MediaChunkIterator!
```

An empty media chunk iterator without available data.

## Public functions

### getChunkEndTimeUs

```
fun getChunkEndTimeUs(): Long
```

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/NoSuchElementException.html` | If the method is called before the first call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#next()` or when `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#isEnded()` is true. |

### getChunkStartTimeUs

```
fun getChunkStartTimeUs(): Long
```

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/NoSuchElementException.html` | If the method is called before the first call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#next()` or when `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#isEnded()` is true. |

### getDataSpec

```
fun getDataSpec(): DataSpec!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/datasource/DataSpec` used to load the media chunk.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/NoSuchElementException.html` | If the method is called before the first call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#next()` or when `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#isEnded()` is true. |

### getLocationSteeringPriorityIndex

```
fun getLocationSteeringPriorityIndex(): Int
```

Returns the index in the steering priority list of the locations (e.g., DASH service location or HLS pathway) for the current media chunks, or `Integer.MAX_VALUE` if steering is inactive or unavailable.

The returned index is only meaningful relatively among candidate tracks (i.e. a lower numerical value indicates a higher priority, with `0` being the top priority).

### isEnded

```
fun isEnded(): Boolean
```

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

### next

```
fun next(): Boolean
```

Moves the iterator to the next media chunk.

Check the return value or `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaChunkIterator#isEnded()` to determine whether the iterator reached the end of the available data.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the iterator points to a media chunk with available data. |

### reset

```
fun reset(): Unit
```

Resets the iterator to the initial position.