# CompositeMediaSource

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

*** ** * ** ***


```
@UnstableApi
public abstract class CompositeMediaSource<T extends Object> extends BaseMediaSource
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.media3.exoplayer.source.BaseMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource) ||
|   | ↳ | [androidx.media3.exoplayer.source.CompositeMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource) |

Known direct subclasses [AdsMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource), [ConcatenatingMediaSource2](https://developer.android.com/reference/androidx/media3/exoplayer/source/ConcatenatingMediaSource2), [ConcatenatingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ConcatenatingMediaSource), [ImaServerSideAdInsertionMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource), [MergingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/MergingMediaSource), [WrappingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/ads/AdsMediaSource` | A `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` that inserts ads linearly into a provided content media source. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/ConcatenatingMediaSource2` | Concatenates multiple `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource`, combining everything in one single `https://developer.android.com/reference/androidx/media3/common/Timeline.Window`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/ConcatenatingMediaSource` | **This class is deprecated.** Use playlist modification methods like `https://developer.android.com/reference/androidx/media3/common/Player#addMediaItem(androidx.media3.common.MediaItem)` instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource` | MediaSource for IMA server side inserted ad streams. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MergingMediaSource` | Merges multiple `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource`s. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource` | An abstract `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` wrapping a single child `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource`. |

Known indirect subclasses [ClippingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource), [FilteringMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/FilteringMediaSource), [LoopingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/LoopingMediaSource), [MaskingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/MaskingMediaSource), [PreloadMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` that wraps a source and clips its timeline based on specified start/end positions. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/FilteringMediaSource` | A `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` that filters the available `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/LoopingMediaSource` | **This class is deprecated.** To loop a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` indefinitely, use `https://developer.android.com/reference/androidx/media3/common/Player#setRepeatMode(int)` instead of this class. <br /> |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MaskingMediaSource` | A `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` that masks the `https://developer.android.com/reference/androidx/media3/common/Timeline` with a placeholder until the actual media structure is known. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/preload/PreloadMediaSource` | Preloads a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` and provides a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` that has data loaded before playback. |

*** ** * ** ***

Composite `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` consisting of multiple child sources.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | The type of the id used to identify prepared child sources. |

## Summary

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#CompositeMediaSource()()` Creates composite media source without child sources. |

| ### Public methods |
|---|---|
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#maybeThrowSourceInfoRefreshError()()` Throws any pending error encountered while loading or refreshing source information. |

| ### Protected methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#disableChildSource(T)(@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id)` Disables a child source. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#disableInternal()()` Disables the source, see `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#disable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#enableChildSource(T)(@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id)` Enables a child source. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#enableInternal()()` Enables the source, see `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#enable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#getMediaPeriodIdForChildMediaPeriodId(T,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)( @https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId, https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId )` Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in the composite source corresponding to the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in a child source. |
| `long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#getMediaTimeForChildMediaTime(T,long,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)( @https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId, long mediaTimeMs, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId )` Returns the media time in the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the composite source corresponding to the specified media time in the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the child source. |
| `int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#getWindowIndexForChildWindowIndex(T,int)( @https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId, int windowIndex )` Returns the window index in the composite source corresponding to the specified window index in a child source. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#onChildSourceInfoRefreshed(T,androidx.media3.exoplayer.source.MediaSource,androidx.media3.common.Timeline)( @https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId, https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource, https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline )` Called when the source info of a child source has been refreshed. |
| `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#prepareChildSource(T,androidx.media3.exoplayer.source.MediaSource)(@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id, https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource)` Prepares a child source. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#prepareSourceInternal(androidx.media3.datasource.TransferListener)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/datasource/TransferListener mediaTransferListener)` Starts source preparation and enables the source, see `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)`. |
| `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#releaseChildSource(T)(@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id)` Releases a child source. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/CallSuper https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#releaseSourceInternal()()` Releases the source, see `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#releaseSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`. |

### Inherited fields

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

### Inherited methods

From [androidx.media3.exoplayer.source.BaseMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource) `final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#addDrmEventListener(android.os.Handler,androidx.media3.exoplayer.drm.DrmSessionEventListener)(
https://developer.android.com/reference/android/os/Handler.html handler,
https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener eventListener
)`

Adds a `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener` to the list of listeners which are notified of DRM events for this media source.
`final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#addEventListener(android.os.Handler,androidx.media3.exoplayer.source.MediaSourceEventListener)(
https://developer.android.com/reference/android/os/Handler.html handler,
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener eventListener
)`

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

Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher` which dispatches all events to the registered listeners with the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`
`final https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#createDrmEventDispatcher(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(
int windowIndex,
@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId
)`

Returns a `https://developer.android.com/reference/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/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`.
`final https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId)`

Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` which dispatches all events to the registered listeners with the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`.
`final https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` `[createEventDispatcher](https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,long))(
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId,
long mediaTimeOffsetMs
)`

**This method is deprecated.**

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

<br />

`final https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(
int windowIndex,
@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId
)`

Returns a `https://developer.android.com/reference/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/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`.
`final https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` `[createEventDispatcher](https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#createEventDispatcher(int,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,long))(
int windowIndex,
@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId,
long mediaTimeOffsetMs
)`

**This method is deprecated.**

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

<br />

`final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#disable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller caller)`

Disables the source for the creation of `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.
`final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#enable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller caller)`

Enables the source for the creation of `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.
`final https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#getBandwidthMeter()()`

Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter` that is used by this media source.
`final https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#getPlayerId()()`

Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId` of the player using this media source.
`final boolean` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#isEnabled()()`

Returns whether the source is enabled.
`final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)(
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller caller,
https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId playerId,
https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter bandwidthMeter
)`

Registers a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller`.
`final boolean` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#prepareSourceCalled()()`

Returns whether the source has `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.exoplayer.analytics.PlayerId,androidx.media3.exoplayer.upstream.BandwidthMeter)` called.
`final void` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#refreshSourceInfo(androidx.media3.common.Timeline)(https://developer.android.com/reference/androidx/media3/common/Timeline timeline)`

Updates timeline and manifest and notifies all listeners of the update.
`final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#releaseSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller caller)`

Unregisters a caller, and disables and releases the source if no longer required.
`final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#removeDrmEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener)(https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener eventListener)`

Removes a `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener` from the list of listeners which are notified of DRM events for this media source.
`final void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#removeEventListener(androidx.media3.exoplayer.source.MediaSourceEventListener)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener eventListener)`

Removes a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener` from the list of listeners which are notified of media source events.
`final void` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#setBandwidthMeter(androidx.media3.exoplayer.upstream.BandwidthMeter)(https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter bandwidthMeter)`

Sets the `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/BandwidthMeter` to be used by this media source.
`final void` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#setPlayerId(androidx.media3.exoplayer.analytics.PlayerId)(https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId playerId)`

Sets the `https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId` of the player using this media source.
From [androidx.media3.exoplayer.source.MediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource) `boolean` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#canUpdateMediaItem(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)`

Returns whether the `https://developer.android.com/reference/androidx/media3/common/MediaItem` for this source can be updated with the provided item.
`abstract https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#createPeriod(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.exoplayer.upstream.Allocator,long)(
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId id,
https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator allocator,
long startPositionUs
)`

Returns a new `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` identified by `periodId`.
`@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/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.
`abstract https://developer.android.com/reference/androidx/media3/common/MediaItem` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#getMediaItem()()`

Returns the `https://developer.android.com/reference/androidx/media3/common/MediaItem` whose media is provided by the source.
`boolean` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#isSingleWindow()()`

Returns true if the media source is guaranteed to never have zero or more than one window.
`void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
[prepareSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#prepareSource(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller,androidx.media3.datasource.TransferListener,androidx.media3.exoplayer.analytics.PlayerId))(
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaSourceCaller caller,
@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/datasource/TransferListener mediaTransferListener,
https://developer.android.com/reference/androidx/media3/exoplayer/analytics/PlayerId playerId
)`

**This method is deprecated.**

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

<br />

`abstract void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#releasePeriod(androidx.media3.exoplayer.source.MediaPeriod)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod mediaPeriod)`

Releases the period.
`void` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#updateMediaItem(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)`

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

## Protected constructors

### CompositeMediaSource

```
protected CompositeMediaSource()
```

Creates composite media source without child sources.

## Public methods

### maybeThrowSourceInfoRefreshError

```
@CallSuper
public void maybeThrowSourceInfoRefreshError()
```

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/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` |   |

## Protected methods

### disableChildSource

```
protected final void disableChildSource(@UnknownNull T id)
```

Disables a child source.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id` | The unique id used to prepare the child source. |

### disableInternal

```
@CallSuper
protected void disableInternal()
```

Disables the source, see `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#disable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`.

### enableChildSource

```
protected final void enableChildSource(@UnknownNull T id)
```

Enables a child source.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id` | The unique id used to prepare the child source. |

### enableInternal

```
@CallSuper
protected void enableInternal()
```

Enables the source, see `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#enable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`.

### getMediaPeriodIdForChildMediaPeriodId

```
protected @Nullable MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(
    @UnknownNull T childSourceId,
    MediaSource.MediaPeriodId mediaPeriodId
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId` | The unique id used to prepare the child source. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId` | A `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` of the child source. |

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

### getMediaTimeForChildMediaTime

```
protected long getMediaTimeForChildMediaTime(
    @UnknownNull T childSourceId,
    long mediaTimeMs,
    @Nullable MediaSource.MediaPeriodId mediaPeriodId
)
```

Returns the media time in the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the composite source corresponding to the specified media time in the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the child source. The default implementation does not change the media time.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId` | The unique id used to prepare the child source. |
| `long mediaTimeMs` | A media time in the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the child source, in milliseconds. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId` | The `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` of the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the child source, or null if the time does not relate to a specific `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`. |

| Returns |
|---|---|
| `long` | The corresponding media time in the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the composite source, in milliseconds. |

### getWindowIndexForChildWindowIndex

```
protected int getWindowIndexForChildWindowIndex(
    @UnknownNull T childSourceId,
    int windowIndex
)
```

Returns the window index in the composite source corresponding to the specified window index in a child source. The default implementation does not change the window index.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId` | The unique id used to prepare the child source. |
| `int windowIndex` | A window index of the child source. |

| Returns |
|---|---|
| `int` | The corresponding window index in the composite source. |

### onChildSourceInfoRefreshed

```
protected abstract void onChildSourceInfoRefreshed(
    @UnknownNull T childSourceId,
    MediaSource mediaSource,
    Timeline newTimeline
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T childSourceId` | The unique id used to prepare the child source. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource` | The child source whose source info has been refreshed. |
| `https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline` | The timeline of the child source. |

### prepareChildSource

```
protected final void prepareChildSource(@UnknownNull T id, MediaSource mediaSource)
```

Prepares a child source.

`https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#onChildSourceInfoRefreshed(T,androidx.media3.exoplayer.source.MediaSource,androidx.media3.common.Timeline)` will be called when the child source updates its timeline with the same `id` passed to this method.

Any child sources that aren't explicitly released with `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#releaseChildSource(T)` will be released in `https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource#releaseSourceInternal()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id` | A unique id to identify the child source preparation. Null is allowed as an id. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource` | The child `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource`. |

### prepareSourceInternal

```
@CallSuper
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)
```

Starts source preparation and enables the source, see `https://developer.android.com/reference/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/androidx/media3/exoplayer/source/BaseMediaSource#releaseSourceInternal()`.

This method is called on the playback thread.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/datasource/TransferListener mediaTransferListener` | 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. |

### releaseChildSource

```
protected final void releaseChildSource(@UnknownNull T id)
```

Releases a child source.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnknownNull T id` | The unique id used to prepare the child source. |

### releaseSourceInternal

```
@CallSuper
protected void releaseSourceInternal()
```

Releases the source, see `https://developer.android.com/reference/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/androidx/media3/exoplayer/source/BaseMediaSource#prepareSourceInternal(androidx.media3.datasource.TransferListener)`.

This method is called on the playback thread.