# MergingMediaSource

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

*** ** * ** ***


```
@UnstableApi
class MergingMediaSource : CompositeMediaSource<Int!>
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [androidx.media3.exoplayer.source.BaseMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource) |||
|   | ↳ | [androidx.media3.exoplayer.source.CompositeMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource)\<[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)!\> ||
|   |   | ↳ | [androidx.media3.exoplayer.source.MergingMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource) |

*** ** * ** ***

Merges multiple `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource`s.

The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`s of the sources being merged must have the same number of periods.

The values of `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup#id()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Format#id()` are modified to start with `i:`, where `i` is the 0-based index of the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` passed to the constructor that created this `https://developer.android.com/reference/kotlin/androidx/media3/common/TrackGroup` or `https://developer.android.com/reference/kotlin/androidx/media3/common/Format`.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource.IllegalMergeException : https://developer.android.com/reference/java/io/IOException.html` Thrown when a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource` cannot merge its sources. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/kotlin/androidx/annotation/IntDef(value = ) annotation https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource.IllegalMergeException.Reason` The reason the merge failed. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#MergingMediaSource(androidx.media3.exoplayer.source.MediaSource...)(mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>!)` Creates a merging media source. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#MergingMediaSource(boolean,androidx.media3.exoplayer.source.MediaSource...)( adjustPeriodTimeOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>! )` Creates a merging media source. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#MergingMediaSource(boolean,boolean,androidx.media3.exoplayer.source.MediaSource...)( adjustPeriodTimeOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, clipDurations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>! )` Creates a merging media source. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#MergingMediaSource(boolean,boolean,androidx.media3.exoplayer.source.CompositeSequenceableLoaderFactory,androidx.media3.exoplayer.source.MediaSource...)( adjustPeriodTimeOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, clipDurations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, compositeSequenceableLoaderFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeSequenceableLoaderFactory!, mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>! )` Creates a merging media source. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#canUpdateMediaItem(androidx.media3.common.MediaItem)(mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!)` Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` for this source can be updated with the provided item. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#createPeriod(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.exoplayer.upstream.Allocator,long)( id: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId!, allocator: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Allocator!, startPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Returns a new `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod` identified by `periodId`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#getMediaItem()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` whose media is provided by the source. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#maybeThrowSourceInfoRefreshError()()` Throws any pending error encountered while loading or refreshing source information. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#releasePeriod(androidx.media3.exoplayer.source.MediaPeriod)(mediaPeriod: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod!)` Releases the period. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#updateMediaItem(androidx.media3.common.MediaItem)(mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!)` Updates the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` for this source. |

| ### Protected functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#getMediaPeriodIdForChildMediaPeriodId(java.lang.Integer,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)( childSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId! )` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in the composite source corresponding to the specified `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in a child source. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#onChildSourceInfoRefreshed(java.lang.Integer,androidx.media3.exoplayer.source.MediaSource,androidx.media3.common.Timeline)( childSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, mediaSource: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!, newTimeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline! )` Called when the source info of a child source has been refreshed. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#prepareSourceInternal(androidx.media3.datasource.TransferListener)(mediaTransferListener: https://developer.android.com/reference/kotlin/androidx/media3/datasource/TransferListener?)` Starts source preparation and enables the source, see `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MergingMediaSource#releaseSourceInternal()()` Releases the source, see `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#releaseSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`. |

### Inherited functions

From [androidx.media3.exoplayer.source.BaseMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#addDrmEventListener(android.os.Handler,androidx.media3.exoplayer.drm.DrmSessionEventListener)(
handler: https://developer.android.com/reference/android/os/Handler.html!,
eventListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener!
)`

Adds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener` to the list of listeners which are notified of DRM events for this media source.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#addEventListener(android.os.Handler,androidx.media3.exoplayer.source.MediaSourceEventListener)(
handler: https://developer.android.com/reference/android/os/Handler.html!,
eventListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener!
)`

Adds a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener` to the list of listeners which are notified of media source events.
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createDrmEventDispatcher(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?)`

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher` which dispatches all events to the registered listeners with the specified `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createDrmEventDispatcher(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(
windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?
)`

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher` which dispatches all events to the registered listeners with the specified window index and `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`.
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?)`

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` which dispatches all events to the registered listeners with the specified `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`.
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher!` `[createEventDispatcher](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,long))(
mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId!,
mediaTimeOffsetMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html
)`

**This function is deprecated.**

Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)` instead.

<br />

`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(
windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?
)`

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` which dispatches all events to the registered listeners with the specified window index and `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`.
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher!` `[createEventDispatcher](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,long))(
windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?,
mediaTimeOffsetMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html
)`

**This function is deprecated.**

Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)` instead.

<br />

`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#disable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)(caller: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller!)`

Disables the source for the creation of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#enable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)(caller: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller!)`

Enables the source for the creation of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#isEnabled()()`

Returns whether the source is enabled.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)(
caller: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller!,
playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId!,
bandwidthMeter: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter!
)`

Registers a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#prepareSourceCalled()()`

Returns whether the source has `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)` called.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#refreshSourceInfo(androidx.media3.common.Timeline)(timeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!)`

Updates timeline and manifest and notifies all listeners of the update.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#releaseSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)(caller: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller!)`

Unregisters a caller, and disables and releases the source if no longer required.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#removeDrmEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener)(eventListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener!)`

Removes a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/drm/DrmSessionEventListener` from the list of listeners which are notified of DRM events for this media source.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#removeEventListener(androidx.media3.exoplayer.source.MediaSourceEventListener)(eventListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener!)`

Removes a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSourceEventListener` from the list of listeners which are notified of media source events.
From [androidx.media3.exoplayer.source.CompositeMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#disableChildSource(T)(@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnknownNull id: T!)`

Disables a child source.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#disableInternal()()`

Disables the source, see `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#disable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#enableChildSource(T)(@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnknownNull id: T!)`

Enables a child source.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/CallSuper
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#enableInternal()()`

Enables the source, see `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#enable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#getMediaTimeForChildMediaTime(T,long,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(
@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnknownNull childSourceId: T!,
mediaTimeMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html,
mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?
)`

Returns the media time in the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod` of the composite source corresponding to the specified media time in the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod` of the child source.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#getWindowIndexForChildWindowIndex(T,int)(
@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnknownNull childSourceId: T!,
windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html
)`

Returns the window index in the composite source corresponding to the specified window index in a child source.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#prepareChildSource(T,androidx.media3.exoplayer.source.MediaSource)(@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnknownNull id: T!, mediaSource: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!)`

Prepares a child source.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeMediaSource#releaseChildSource(T)(@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnknownNull id: T!)`

Releases a child source.
From [androidx.media3.exoplayer.source.MediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource) `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline?` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#getInitialTimeline()()`

Returns the initial placeholder timeline that is returned immediately when the real timeline is not yet known, or null to let the player create an initial timeline.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#isSingleWindow()()`

Returns true if the media source is guaranteed to never have zero or more than one window.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi
[prepareSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.datasource.TransferListener,androidx.media3.exoplayer.analytics.PlayerId))(
caller: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller!,
mediaTransferListener: https://developer.android.com/reference/kotlin/androidx/media3/datasource/TransferListener?,
playerId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId!
)`

**This function is deprecated.**

Use `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)` instead.

<br />

### Inherited properties

From [androidx.media3.exoplayer.source.BaseMediaSource](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource) `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/BandwidthMeter?` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#bandwidthMeter()` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/analytics/PlayerId?` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#playerId()`

## Public constructors

### MergingMediaSource

```
MergingMediaSource(mediaSources: Array<MediaSource!>!)
```

Creates a merging media source.

Neither offsets between the timestamps in the media sources nor the durations of the media sources will be adjusted.

| Parameters |
|---|---|
| `mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` to merge. |

### MergingMediaSource

```
MergingMediaSource(
    adjustPeriodTimeOffsets: Boolean,
    mediaSources: Array<MediaSource!>!
)
```

Creates a merging media source.

Durations of the media sources will not be adjusted.

| Parameters |
|---|---|
| `adjustPeriodTimeOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to adjust timestamps of the merged media sources to all start at the same time. |
| `mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` to merge. |

### MergingMediaSource

```
MergingMediaSource(
    adjustPeriodTimeOffsets: Boolean,
    clipDurations: Boolean,
    mediaSources: Array<MediaSource!>!
)
```

Creates a merging media source.

| Parameters |
|---|---|
| `adjustPeriodTimeOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to adjust timestamps of the merged media sources to all start at the same time. |
| `clipDurations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to clip the durations of the media sources to match the shortest duration. |
| `mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` to merge. |

### MergingMediaSource

```
MergingMediaSource(
    adjustPeriodTimeOffsets: Boolean,
    clipDurations: Boolean,
    compositeSequenceableLoaderFactory: CompositeSequenceableLoaderFactory!,
    mediaSources: Array<MediaSource!>!
)
```

Creates a merging media source.

| Parameters |
|---|---|
| `adjustPeriodTimeOffsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to adjust timestamps of the merged media sources to all start at the same time. |
| `clipDurations: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether to clip the durations of the media sources to match the shortest duration. |
| `compositeSequenceableLoaderFactory: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/CompositeSequenceableLoaderFactory!` | A factory to create composite `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SequenceableLoader`s for when this media source loads data from multiple streams (video, audio etc...). |
| `mediaSources: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!>!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource` to merge. |

## Public functions

### canUpdateMediaItem

```
fun canUpdateMediaItem(mediaItem: MediaItem!): Boolean
```

Returns whether the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` for this source can be updated with the provided item.

Should not be called directly from application code.

This method must be called on the application thread.

| Parameters |
|---|---|
| `mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | The new `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the source can be updated using this item. |

### createPeriod

```
fun createPeriod(
    id: MediaSource.MediaPeriodId!,
    allocator: Allocator!,
    startPositionUs: Long
): MediaPeriod!
```

Returns a new `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod` identified by `periodId`.

Should not be called directly from application code.

This method must be called on the playback thread and only if the source is enabled.

| Parameters |
|---|---|
| `id: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId!` | The identifier of the period. |
| `allocator: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Allocator!` | An `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/upstream/Allocator` from which to obtain media buffer allocations. |
| `startPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The expected start position, in microseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod!` | A new `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod`. |

### getMediaItem

```
fun getMediaItem(): MediaItem!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` whose media is provided by the source.

Should not be called directly from application code.

This method must be called on the application thread.

### maybeThrowSourceInfoRefreshError

```
fun maybeThrowSourceInfoRefreshError(): Unit
```

Throws any pending error encountered while loading or refreshing source information.

Should not be called directly from application code.

This method must be called on the playback thread and only after `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### releasePeriod

```
fun releasePeriod(mediaPeriod: MediaPeriod!): Unit
```

Releases the period.

Should not be called directly from application code.

This method must be called on the playback thread.

| Parameters |
|---|---|
| `mediaPeriod: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaPeriod!` | The period to release. |

### updateMediaItem

```
fun updateMediaItem(mediaItem: MediaItem!): Unit
```

Updates the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` for this source.

Should not be called directly from application code.

This method must be called on the playback thread and only if `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#canUpdateMediaItem(androidx.media3.common.MediaItem)` returns `true` for the new `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`.

| Parameters |
|---|---|
| `mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | The new `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |

## Protected functions

### getMediaPeriodIdForChildMediaPeriodId

```
protected fun getMediaPeriodIdForChildMediaPeriodId(
    childSourceId: Int!,
    mediaPeriodId: MediaSource.MediaPeriodId!
): MediaSource.MediaPeriodId?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in the composite source corresponding to the specified `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in a child source. The default implementation does not change the media period id.

| Parameters |
|---|---|
| `childSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!` | The unique id used to prepare the child source. |
| `mediaPeriodId: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId!` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` of the child source. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId?` | The corresponding `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in the composite source. Null if no corresponding media period id can be determined. |

### onChildSourceInfoRefreshed

```
protected fun onChildSourceInfoRefreshed(
    childSourceId: Int!,
    mediaSource: MediaSource!,
    newTimeline: Timeline!
): Unit
```

Called when the source info of a child source has been refreshed.

| Parameters |
|---|---|
| `childSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!` | The unique id used to prepare the child source. |
| `mediaSource: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource!` | The child source whose source info has been refreshed. |
| `newTimeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | The timeline of the child source. |

### prepareSourceInternal

```
protected fun prepareSourceInternal(mediaTransferListener: TransferListener?): Unit
```

Starts source preparation and enables the source, see `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)`. This method is called at most once until the next call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#releaseSourceInternal()`.

This method is called on the playback thread.

| Parameters |
|---|---|
| `mediaTransferListener: https://developer.android.com/reference/kotlin/androidx/media3/datasource/TransferListener?` | The transfer listener which should be informed of any media data transfers. May be null if no listener is available. Note that this listener should usually be only informed of transfers related to the media loads and not of auxiliary loads for manifests and other data. |

### releaseSourceInternal

```
protected fun releaseSourceInternal(): Unit
```

Releases the source, see `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MediaSource#releaseSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`. This method is called exactly once after each call to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/BaseMediaSource#prepareSourceInternal(androidx.media3.datasource.TransferListener)`.

This method is called on the playback thread.