# MediaParserChunkExtractor

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/MediaParserChunkExtractor.java+class:androidx.media3.exoplayer.source.chunk.MediaParserChunkExtractor)

*** ** * ** ***


```
@RequiresApi(value = 30)
@UnstableApi
public final class MediaParserChunkExtractor implements ChunkExtractor
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor` implemented on top of the platform's `https://developer.android.com/reference/android/media/MediaParser.html`.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor.Factory implements https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` A `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` for `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor` instances. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#FACTORY()` **This field is deprecated.** `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` is mutable, so a static instance is not safe. <br /> |

| ### Public fields |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable Format[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#sampleFormats()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#MediaParserChunkExtractor(int,androidx.media3.common.Format,java.util.List<androidx.media3.common.Format>,androidx.media3.exoplayer.analytics.PlayerId)( @https://developer.android.com/reference/androidx/media3/common/C.TrackType int primaryTrackType, https://developer.android.com/reference/androidx/media3/common/Format manifestFormat, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> closedCaptionFormats, https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId playerId )` Creates a new instance. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#getChunkIndex()()` Returns the `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` most recently obtained from the chunks, or null if a `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` has not been obtained. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable Format[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#getSampleFormats()()` Returns the sample `https://developer.android.com/reference/androidx/media3/common/Format`s for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#init(androidx.media3.exoplayer.source.chunk.ChunkExtractor.TrackOutputProvider,long,long)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider trackOutputProvider, long startTimeUs, long endTimeUs )` Initializes the wrapper to output to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s provided by the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider`, and configures the extractor to receive data from a new chunk. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#read(androidx.media3.extractor.ExtractorInput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input)` Reads from the given `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#release()()` Releases any held resources. |

## Constants

### FACTORY

```
public static final ChunkExtractor.Factory FACTORY
```

> [!CAUTION]
> **This field is deprecated.**   
>
> `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` is mutable, so a static instance is not safe. Instantiate a new `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor.Factory` instead.

## Public fields

### sampleFormats

```
public @Nullable Format[] sampleFormats
```

## Public constructors

### MediaParserChunkExtractor

```
public MediaParserChunkExtractor(
    @C.TrackType int primaryTrackType,
    Format manifestFormat,
    List<Format> closedCaptionFormats,
    PlayerId playerId
)
```

Creates a new instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.TrackType int primaryTrackType` | The `https://developer.android.com/reference/androidx/media3/common/C.TrackType` of the primary track. `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_NONE()` if there is no primary track. |
| `https://developer.android.com/reference/androidx/media3/common/Format manifestFormat` | The chunks `https://developer.android.com/reference/androidx/media3/common/Format` as obtained from the manifest. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> closedCaptionFormats` | A list containing the `https://developer.android.com/reference/androidx/media3/common/Format` of the closed-caption tracks in the chunks. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId playerId` | The `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId` of the player this chunk extractor is used for. |

## Public methods

### getChunkIndex

```
public @Nullable ChunkIndex getChunkIndex()
```

Returns the `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` most recently obtained from the chunks, or null if a `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` has not been obtained.

### getSampleFormats

```
public @Nullable Format[] getSampleFormats()
```

Returns the sample `https://developer.android.com/reference/androidx/media3/common/Format`s for the tracks identified by the extractor, or null if the extractor has not finished identifying tracks.

### init

```
public void init(
    @Nullable ChunkExtractor.TrackOutputProvider trackOutputProvider,
    long startTimeUs,
    long endTimeUs
)
```

Initializes the wrapper to output to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s provided by the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider`, and configures the extractor to receive data from a new chunk.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider trackOutputProvider` | The provider of `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s that will receive sample data. |
| `long startTimeUs` | The start position in the new chunk, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to output samples from the start of the chunk. |
| `long endTimeUs` | The end position in the new chunk, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` to output samples to the end of the chunk. |

### read

```
public boolean read(ExtractorInput input)
```

Reads from the given `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input` | The input to read from. |

| Returns |
|---|---|
| `boolean` | Whether there is any data left to extract. Returns false if the end of input has been reached. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from or parsing the input. |

### release

```
public void release()
```

Releases any held resources.