# MediaParserHlsMediaChunkExtractor

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

*** ** * ** ***

<br />

```
@RequiresApi(value = 30)
@UnstableApi
class MediaParserHlsMediaChunkExtractor : HlsMediaChunkExtractor
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsMediaChunkExtractor` implemented on top of the platform's `https://developer.android.com/reference/android/media/MediaParser.html`.

## Summary

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsExtractorFactory!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#FACTORY()` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsExtractorFactory` implementation that produces `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor` for all container formats except WebVTT, for which a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/BundledHlsMediaChunkExtractor` is returned. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#MediaParserHlsMediaChunkExtractor(android.media.MediaParser,androidx.media3.exoplayer.source.mediaparser.OutputConsumerAdapterV30,androidx.media3.common.Format,boolean,com.google.common.collect.ImmutableList<android.media.MediaFormat>,int,androidx.media3.exoplayer.analytics.PlayerId)( mediaParser: https://developer.android.com/reference/android/media/MediaParser.html!, outputConsumerAdapter: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/mediaparser/OutputConsumerAdapterV30!, format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!, overrideInBandCaptionDeclarations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, muxedCaptionMediaFormats: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/android/media/MediaFormat.html!>!, leadingBytesToSkip: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId! )` Creates a new instance. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#init(androidx.media3.extractor.ExtractorOutput)(extractorOutput: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput!)` Initializes the extractor with an `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#isPackedAudioExtractor()()` Returns whether this is a packed audio extractor, as defined in RFC 8216, Section 3.4. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#isReusable()()` Returns whether this instance can be used for extracting multiple continuous segments. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#onTruncatedSegmentParsed()()` Resets the sample parsing state. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#read(androidx.media3.extractor.ExtractorInput)(extractorInput: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput!)` Extracts data read from a provided `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsMediaChunkExtractor!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor#recreate()()` Returns a new instance for extracting the same type of media as this one. |

## Constants

### FACTORY

```
const val FACTORY: HlsExtractorFactory!
```

`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsExtractorFactory` implementation that produces `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/MediaParserHlsMediaChunkExtractor` for all container formats except WebVTT, for which a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/BundledHlsMediaChunkExtractor` is returned.

## Public constructors

### MediaParserHlsMediaChunkExtractor

```
MediaParserHlsMediaChunkExtractor(
    mediaParser: MediaParser!,
    outputConsumerAdapter: OutputConsumerAdapterV30!,
    format: Format!,
    overrideInBandCaptionDeclarations: Boolean,
    muxedCaptionMediaFormats: ImmutableList<MediaFormat!>!,
    leadingBytesToSkip: Int,
    playerId: PlayerId!
)
```

Creates a new instance.

| Parameters |
|---|---|
| `mediaParser: https://developer.android.com/reference/android/media/MediaParser.html!` | The `https://developer.android.com/reference/android/media/MediaParser.html` instance to use for extraction of segments. The provided instance must have completed sniffing, or must have been created by name. |
| `outputConsumerAdapter: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/mediaparser/OutputConsumerAdapterV30!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/mediaparser/OutputConsumerAdapterV30` with which ` mediaParser` was created. |
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Format` associated with the segment. |
| `overrideInBandCaptionDeclarations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to ignore any in-band caption track declarations in favor of using the `muxedCaptionMediaFormats` instead. If false, caption declarations found in the extracted media will be used, causing ` muxedCaptionMediaFormats` to be ignored instead. |
| `muxedCaptionMediaFormats: https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/android/media/MediaFormat.html!>!` | The list of in-band caption `https://developer.android.com/reference/android/media/MediaFormat.html` that `https://developer.android.com/reference/android/media/MediaParser.html` should expose. |
| `leadingBytesToSkip: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes to skip from the start of the input before starting extraction. |
| `playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId` of the player using this chunk extractor. |

## Public functions

### init

```
fun init(extractorOutput: ExtractorOutput!): Unit
```

Initializes the extractor with an `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput`. Called at most once.

| Parameters |
|---|---|
| `extractorOutput: https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput!` | An `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput` to receive extracted data. |

### isPackedAudioExtractor

```
fun isPackedAudioExtractor(): Boolean
```

Returns whether this is a packed audio extractor, as defined in RFC 8216, Section 3.4.

### isReusable

```
fun isReusable(): Boolean
```

Returns whether this instance can be used for extracting multiple continuous segments.

### onTruncatedSegmentParsed

```
fun onTruncatedSegmentParsed(): Unit
```

Resets the sample parsing state.

Resetting the parsing state allows support for Fragmented MP4 EXT-X-I-FRAME-STREAM-INF segments. EXT-X-I-FRAME-STREAM-INF segments are truncated to include only a leading key frame. After parsing said keyframe, an extractor may reach an unexpected end of file. By resetting its state, we can continue feeding samples from the following segments to the extractor. See [#7512](https://github.com/google/ExoPlayer/issues/7512) for context.

### read

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

Extracts data read from a provided `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput`. Must not be called before `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsMediaChunkExtractor#init(androidx.media3.extractor.ExtractorOutput)`.

A single call to this method will block until some progress has been made, but will not block for longer than this. Hence each call will consume only a small amount of input data.

When this method throws an `https://developer.android.com/reference/java/io/IOException.html`, extraction may continue by providing an `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput` with an unchanged `https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorInput#getPosition()` to a subsequent call to this method.

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

| Returns |
|---|---|
| `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 |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurred reading from or parsing the input. |

### recreate

```
fun recreate(): HlsMediaChunkExtractor!
```

Returns a new instance for extracting the same type of media as this one. Can only be called on instances that are not `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/hls/HlsMediaChunkExtractor#isReusable()`.