# MediaParserChunkExtractor

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor "View this page in Java")

<br />

```
@RequiresApi(value = 30)
@UnstableApi
class MediaParserChunkExtractor : ChunkExtractor
```

<br />

*** ** * ** ***

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

## Summary

|                                                                                                                                                                                                                                                                                                 ### Nested types                                                                                                                                                                                                                                                                                                 |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[MediaParserChunkExtractor.Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor.Factory)` : `[ChunkExtractor.Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory) A[ChunkExtractor.Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory)for[MediaParserChunkExtractor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor)instances. |

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

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [MediaParserChunkExtractor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#MediaParserChunkExtractor(int,androidx.media3.common.Format,java.util.List<androidx.media3.common.Format>,androidx.media3.exoplayer.analytics.PlayerId))`(` ` @`[C.TrackType](https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType)` primaryTrackType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` manifestFormat: `[Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)`!,` ` closedCaptionFormats: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)`!>!,` ` playerId: `[PlayerId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId)`!` `)` Creates a new instance. |

|                                         ### Public functions                                         |
|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)`?` | [getChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#getChunkIndex())`()` Returns the[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)most recently obtained from the chunks, or null if a[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)has not been obtained.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                        | [init](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#init(androidx.media3.exoplayer.source.chunk.ChunkExtractor.TrackOutputProvider,long,long))`(` ` trackOutputProvider: `[ChunkExtractor.TrackOutputProvider](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider)`?,` ` startTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` endTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) `)` Initializes the wrapper to output to[TrackOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput)s provided by the specified[TrackOutputProvider](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider), and configures the extractor to receive data from a new chunk. |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                  | [read](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#read(androidx.media3.extractor.ExtractorInput))`(input: `[ExtractorInput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput)`!)` Reads from the given[ExtractorInput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                        | [release](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#release())`()` Releases any held resources.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

|                                                                             ### Public properties                                                                             |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)`!>?` | [sampleFormats](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor#sampleFormats()) |

## Constants

### FACTORY

```
const val FACTORY: ChunkExtractor.Factory!
```
| **This property is deprecated.**   
|
[ChunkExtractor.Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory)is mutable, so a static instance is not safe. Instantiate a new[Factory](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/MediaParserChunkExtractor.Factory)instead.  

## Public constructors

### MediaParserChunkExtractor

```
MediaParserChunkExtractor(
    @C.TrackType primaryTrackType: Int,
    manifestFormat: Format!,
    closedCaptionFormats: (Mutable)List<Format!>!,
    playerId: PlayerId!
)
```

Creates a new instance.  

|                                                                                                                                                       Parameters                                                                                                                                                        |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `@`[C.TrackType](https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType)` primaryTrackType: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                     | The[type](https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType)of the primary track.[TRACK_TYPE_NONE](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TRACK_TYPE_NONE())if there is no primary track. |
| `manifestFormat: `[Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)`!`                                                                                                                                                                                                             | The chunks[Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)as obtained from the manifest.                                                                                                                             |
| `closedCaptionFormats: (`[Mutable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)`)`[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)`!>!` | A list containing the[Formats](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)of the closed-caption tracks in the chunks.                                                                                                    |
| `playerId: `[PlayerId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId)`!`                                                                                                                                                                                                  | The[PlayerId](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId)of the player this chunk extractor is used for.                                                                                                  |

## Public functions

### getChunkIndex

```
fun getChunkIndex(): ChunkIndex?
```

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

### init

```
fun init(
    trackOutputProvider: ChunkExtractor.TrackOutputProvider?,
    startTimeUs: Long,
    endTimeUs: Long
): Unit
```

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

|                                                                                        Parameters                                                                                        |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `trackOutputProvider: `[ChunkExtractor.TrackOutputProvider](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/chunk/ChunkExtractor.TrackOutputProvider)`?` | The provider of[TrackOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput)s that will receive sample data.                                      |
| `startTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                                             | The start position in the new chunk, or[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())to output samples from the start of the chunk. |
| `endTimeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                                               | The end position in the new chunk, or[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())to output samples to the end of the chunk.       |

### read

```
fun read(input: ExtractorInput!): Boolean
```

Reads from the given[ExtractorInput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput).  

|                                                      Parameters                                                       |
|-----------------------------------------------------------------------------------------------------------------------|-------------------------|
| `input: `[ExtractorInput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput)`!` | The input to read from. |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | Whether there is any data left to extract. Returns false if the end of input has been reached. |

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

### release

```
fun release(): Unit
```

Releases any held resources.  

## Public properties

### sampleFormats

```
val sampleFormats: Array<Format!>?
```