# BundledChunkExtractor

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

*** ** * ** ***


```
@UnstableApi
public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtractor
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor` implementation that uses ExoPlayer app-bundled `https://developer.android.com/reference/androidx/media3/extractor/Extractor`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor.Factory implements https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/ChunkExtractor.Factory` for `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor`. |
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor.ManifestFormatMerger` Interface for merging `https://developer.android.com/reference/androidx/media3/common/Format` instances from the extracted samples and the manifest. |

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

| ### Public fields |
|---|---|
| `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html Format[]` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor#sampleFormats()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor#BundledChunkExtractor(androidx.media3.extractor.Extractor,int,androidx.media3.common.Format)( https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor, @https://developer.android.com/reference/androidx/media3/common/C.TrackType int primaryTrackType, https://developer.android.com/reference/androidx/media3/common/Format primaryTrackManifestFormat )` Creates an instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor#BundledChunkExtractor(androidx.media3.extractor.Extractor,int,androidx.media3.common.Format,androidx.media3.exoplayer.source.chunk.BundledChunkExtractor.ManifestFormatMerger)( https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor, @https://developer.android.com/reference/androidx/media3/common/C.TrackType int primaryTrackType, https://developer.android.com/reference/androidx/media3/common/Format primaryTrackManifestFormat, https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor.ManifestFormatMerger manifestFormatMerger )` Creates an instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor#endTracks()()` Called when all tracks have been identified, meaning no new `trackId` values will be passed to `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput#track(int,int)`. |
| `@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/BundledChunkExtractor#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/BundledChunkExtractor#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/BundledChunkExtractor#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/BundledChunkExtractor#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/BundledChunkExtractor#release()()` Releases any held resources. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor#seekMap(androidx.media3.extractor.SeekMap)(https://developer.android.com/reference/androidx/media3/extractor/SeekMap seekMap)` Called when a `https://developer.android.com/reference/androidx/media3/extractor/SeekMap` has been extracted from the stream. |
| `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor#track(int,int)(int id, int type)` Called by the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` to get the `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` for a specific track. |

| ### Inherited Constants |
|---|
| From [androidx.media3.extractor.ExtractorOutput](https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput) |---|---| | `static final https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput` | `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput#PLACEHOLDER()` Placeholder `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput` implementation throwing an `https://developer.android.com/reference/java/lang/UnsupportedOperationException.html` in each method. | |

## Constants

### FACTORY

```
public static final BundledChunkExtractor.Factory FACTORY
```

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

## Public fields

### sampleFormats

```
public @MonotonicNonNull Format[] sampleFormats
```

## Public constructors

### BundledChunkExtractor

```
public BundledChunkExtractor(
    Extractor extractor,
    @C.TrackType int primaryTrackType,
    Format primaryTrackManifestFormat
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor` | The extractor to wrap. |
| `@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/Format primaryTrackManifestFormat` | A manifest defined `https://developer.android.com/reference/androidx/media3/common/Format` whose data should be merged into any sample `https://developer.android.com/reference/androidx/media3/common/Format` output from the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` for the primary track. |

### BundledChunkExtractor

```
public BundledChunkExtractor(
    Extractor extractor,
    @C.TrackType int primaryTrackType,
    Format primaryTrackManifestFormat,
    BundledChunkExtractor.ManifestFormatMerger manifestFormatMerger
)
```

Creates an instance.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/Extractor extractor` | The extractor to wrap. |
| `@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/Format primaryTrackManifestFormat` | A manifest defined `https://developer.android.com/reference/androidx/media3/common/Format` whose data should be merged into any sample `https://developer.android.com/reference/androidx/media3/common/Format` output from the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` for the primary track. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor.ManifestFormatMerger manifestFormatMerger` | A `https://developer.android.com/reference/androidx/media3/exoplayer/source/chunk/BundledChunkExtractor.ManifestFormatMerger` to merge the sample format with the manifest format of the primary track. |

## Public methods

### endTracks

```
public void endTracks()
```

Called when all tracks have been identified, meaning no new `trackId` values will be passed to `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput#track(int,int)`.

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

### seekMap

```
public void seekMap(SeekMap seekMap)
```

Called when a `https://developer.android.com/reference/androidx/media3/extractor/SeekMap` has been extracted from the stream.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/SeekMap seekMap` | The extracted `https://developer.android.com/reference/androidx/media3/extractor/SeekMap`. |

### track

```
public TrackOutput track(int id, int type)
```

Called by the `https://developer.android.com/reference/androidx/media3/extractor/Extractor` to get the `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` for a specific track.

The same `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` is returned if multiple calls are made with the same `
id`.

| Parameters |
|---|---|
| `int id` | A track identifier. |
| `int type` | The `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` | The `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput` for the given track identifier. |