# ChunkIndexMerger

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

*** ** * ** ***


```
@UnstableApi
public final class ChunkIndexMerger
```

<br />

*** ** * ** ***

A utility class for merging multiple `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` instances into a single `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex`.

This is useful in scenarios where media is split across multiple segments or sources, and a unified index is needed for seeking or playback.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndexMerger#ChunkIndexMerger()()` Creates an instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndexMerger#add(androidx.media3.extractor.ChunkIndex)(https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex chunk)` Adds a `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` to be merged. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndexMerger#clear()()` Clears all added chunk indices and internal state. |
| `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` | `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndexMerger#merge()()` Returns a single `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` that merges all added chunk indices. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndexMerger#size()()` Returns the number of chunk indices added so far. |

## Public constructors

### ChunkIndexMerger

```
public ChunkIndexMerger()
```

Creates an instance.

## Public methods

### add

```
public void add(ChunkIndex chunk)
```

Adds a `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` to be merged.

Chunk indices with duplicate starting timestamps are ignored to avoid redundant data.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex chunk` | The `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` to add. |

### clear

```
public void clear()
```

Clears all added chunk indices and internal state.

### merge

```
public ChunkIndex merge()
```

Returns a single `https://developer.android.com/reference/androidx/media3/extractor/ChunkIndex` that merges all added chunk indices.

### size

```
public int size()
```

Returns the number of chunk indices added so far.