# HlsExtractorFactory

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/HlsExtractorFactory.java+class:androidx.media3.exoplayer.hls.HlsExtractorFactory)

*** ** * ** ***


```
@UnstableApi
public interface HlsExtractorFactory
```

<br />

Known direct subclasses [DefaultHlsExtractorFactory](https://developer.android.com/reference/androidx/media3/exoplayer/hls/DefaultHlsExtractorFactory)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/DefaultHlsExtractorFactory` | Default `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory` implementation. |

*** ** * ** ***

Factory for HLS media chunk extractors.

## Summary

| ### Constants |
|---|---|
| `default static final https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory#DEFAULT()` **This field is deprecated.** `HlsExtractorFactory` instances are mutable, so sharing one in a static field is not safe. <br /> |

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsMediaChunkExtractor` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory#createExtractor(android.net.Uri,androidx.media3.common.Format,java.util.List<androidx.media3.common.Format>,androidx.media3.common.util.TimestampAdjuster,java.util.Map<java.lang.String,java.util.List<java.lang.String>>,androidx.media3.extractor.ExtractorInput,androidx.media3.exoplayer.analytics.PlayerId)( https://developer.android.com/reference/android/net/Uri.html uri, https://developer.android.com/reference/androidx/media3/common/Format format, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> muxedCaptionFormats, https://developer.android.com/reference/androidx/media3/common/util/TimestampAdjuster timestampAdjuster, https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>> responseHeaders, https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput sniffingExtractorInput, https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId playerId )` Creates an `https://developer.android.com/reference/androidx/media3/extractor/Extractor` for extracting HLS media chunks. |
| `default https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/ExperimentalApi https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory#experimentalParseSubtitlesDuringExtraction(boolean)( boolean parseSubtitlesDuringExtraction )` Sets whether subtitles should be parsed as part of extraction (before being added to the sample queue) or as part of rendering (when being taken from the sample queue). |
| `default https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory#getOutputTextFormat(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format sourceFormat)` Returns the output `https://developer.android.com/reference/androidx/media3/common/Format` of emitted `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_TEXT()` which were originally in `sourceFormat`. |
| `default https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory#setSubtitleParserFactory(androidx.media3.extractor.text.SubtitleParser.Factory)(https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory subtitleParserFactory)` Sets the `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory` to use for parsing subtitles during extraction. |

## Constants

### DEFAULT

```
default static final HlsExtractorFactory DEFAULT
```

> [!CAUTION]
> **This field is deprecated.**   
>
> `HlsExtractorFactory` instances are mutable, so sharing one in a static field is not safe. Construct a new instance of `https://developer.android.com/reference/androidx/media3/exoplayer/hls/DefaultHlsExtractorFactory` for each usage instead.

## Public methods

### createExtractor

```
abstract HlsMediaChunkExtractor createExtractor(
    Uri uri,
    Format format,
    @Nullable List<Format> muxedCaptionFormats,
    TimestampAdjuster timestampAdjuster,
    Map<String, List<String>> responseHeaders,
    ExtractorInput sniffingExtractorInput,
    PlayerId playerId
)
```

Creates an `https://developer.android.com/reference/androidx/media3/extractor/Extractor` for extracting HLS media chunks.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html uri` | The URI of the media chunk. |
| `https://developer.android.com/reference/androidx/media3/common/Format format` | A `https://developer.android.com/reference/androidx/media3/common/Format` associated with the chunk to extract. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> muxedCaptionFormats` | List of muxed caption `https://developer.android.com/reference/androidx/media3/common/Format`s. Null if no closed caption information is available in the multivariant playlist. |
| `https://developer.android.com/reference/androidx/media3/common/util/TimestampAdjuster timestampAdjuster` | Adjuster corresponding to the provided discontinuity sequence number. |
| `https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>> responseHeaders` | The HTTP response headers associated with the media segment or initialization section to extract. |
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput sniffingExtractorInput` | The first extractor input that will be passed to the returned extractor's `https://developer.android.com/reference/androidx/media3/extractor/Extractor#read(androidx.media3.extractor.ExtractorInput,androidx.media3.extractor.PositionHolder)`. Must only be used to call `https://developer.android.com/reference/androidx/media3/extractor/Extractor#sniff(androidx.media3.extractor.ExtractorInput)`. |
| `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 using this extractors factory. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsMediaChunkExtractor` | An `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsMediaChunkExtractor`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an I/O error is encountered while sniffing. |

### experimentalParseSubtitlesDuringExtraction

```
@CanIgnoreReturnValue
@ExperimentalApi
default HlsExtractorFactory experimentalParseSubtitlesDuringExtraction(
    boolean parseSubtitlesDuringExtraction
)
```

Sets whether subtitles should be parsed as part of extraction (before being added to the sample queue) or as part of rendering (when being taken from the sample queue). Defaults to `
false` (i.e. subtitles will be parsed as part of rendering).

This method is experimental and will be renamed or removed in a future release.

| Parameters |
|---|---|
| `boolean parseSubtitlesDuringExtraction` | Whether to parse subtitles during extraction or rendering. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory` | This factory, for convenience. |

### getOutputTextFormat

```
default Format getOutputTextFormat(Format sourceFormat)
```

Returns the output `https://developer.android.com/reference/androidx/media3/common/Format` of emitted `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_TEXT()` which were originally in `sourceFormat`.

In many cases, where an `https://developer.android.com/reference/androidx/media3/extractor/Extractor` emits samples from the source without mutation, this method simply returns `sourceFormat`. In other cases, such as an `https://developer.android.com/reference/androidx/media3/extractor/Extractor` that transcodes subtitles from the `sourceFormat` to `https://developer.android.com/reference/androidx/media3/common/MimeTypes#APPLICATION_MEDIA3_CUES()`, the format is updated to indicate the transcoding that is taking place.

Non-text source formats are always returned without mutation.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format sourceFormat` | The original text-based format. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format` | The `https://developer.android.com/reference/androidx/media3/common/Format` that will be associated with a `https://developer.android.com/reference/androidx/media3/common/C#TRACK_TYPE_TEXT()`. |

### setSubtitleParserFactory

```
@CanIgnoreReturnValue
default HlsExtractorFactory setSubtitleParserFactory(SubtitleParser.Factory subtitleParserFactory)
```

Sets the `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory` to use for parsing subtitles during extraction. The default factory value is implementation dependent.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory subtitleParserFactory` | The `https://developer.android.com/reference/androidx/media3/extractor/text/SubtitleParser.Factory` for parsing subtitles during extraction. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/hls/HlsExtractorFactory` | This factory, for convenience. |