# ChunkIndexMerger

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/extractor/ChunkIndexMerger "View this page in Java")

<br />

```
@UnstableApi
class ChunkIndexMerger
```

<br />

*** ** * ** ***

A utility class for merging multiple[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)instances into a single[ChunkIndex](https://developer.android.com/reference/kotlin/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                                                                  |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ChunkIndexMerger](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndexMerger#ChunkIndexMerger())`()` Creates an instance. |

|                                         ### Public functions                                         |
|------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                        | [add](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndexMerger#add(androidx.media3.extractor.ChunkIndex))`(chunk: `[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)`!)` Adds a[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)to be merged. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                        | [clear](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndexMerger#clear())`()` Clears all added chunk indices and internal state.                                                                                                                                                                                                              |
| [ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)`!` | [merge](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndexMerger#merge())`()` Returns a single[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)that merges all added chunk indices.                                                                                                           |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                          | [size](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndexMerger#size())`()` Returns the number of chunk indices added so far.                                                                                                                                                                                                                 |

## Public constructors

### ChunkIndexMerger

```
ChunkIndexMerger()
```

Creates an instance.  

## Public functions

### add

```
fun add(chunk: ChunkIndex!): Unit
```

Adds a[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)to be merged.

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

|                                                  Parameters                                                   |
|---------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `chunk: `[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)`!` | The[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)to add. |

### clear

```
fun clear(): Unit
```

Clears all added chunk indices and internal state.  

### merge

```
fun merge(): ChunkIndex!
```

Returns a single[ChunkIndex](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ChunkIndex)that merges all added chunk indices.  

### size

```
fun size(): Int
```

Returns the number of chunk indices added so far.