# ClippingMediaSource

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

*** ** * ** ***


```
@UnstableApi
public final class ClippingMediaSource extends WrappingMediaSource
```

<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) |||
|   |   | ↳ | [androidx.media3.exoplayer.source.WrappingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource) ||
|   |   |   | ↳ | [androidx.media3.exoplayer.source.ClippingMediaSource](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. The wrapped source must consist of a single period.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.Builder` A builder for `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource`. |
| `public final class https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.IllegalClippingException extends https://developer.android.com/reference/java/io/IOException.html` Thrown when a `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource` cannot clip its wrapped source. |
| `@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/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.IllegalClippingException.Reason` The reason clipping failed. |

| ### Public constructors |
|---|
| `[ClippingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#ClippingMediaSource(androidx.media3.exoplayer.source.MediaSource,long))(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource, long durationUs)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.Builder` instead. <br /> |
| `[ClippingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#ClippingMediaSource(androidx.media3.exoplayer.source.MediaSource,long,long))( https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource, long startPositionUs, long endPositionUs )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.Builder` instead. <br /> |
| `[ClippingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#ClippingMediaSource(androidx.media3.exoplayer.source.MediaSource,long,long,boolean,boolean,boolean))( https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource mediaSource, long startPositionUs, long endPositionUs, boolean enableInitialDiscontinuity, boolean allowDynamicClippingUpdates, boolean relativeToDefaultPosition )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.Builder` instead. <br /> |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#canUpdateMediaItem(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Returns whether the for this source can be updated with the provided item. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#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 )` Creates the requested `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#maybeThrowSourceInfoRefreshError()()` Throws any pending error encountered while loading or refreshing source information. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#releasePeriod(androidx.media3.exoplayer.source.MediaPeriod)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod mediaPeriod)` Releases a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#updateMediaItem(androidx.media3.common.MediaItem)(https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem)` Updates the for this source. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#onChildSourceInfoRefreshed(androidx.media3.common.Timeline)(https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline)` Called when the child source info has been refreshed. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#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()` | |
| From [androidx.media3.exoplayer.source.WrappingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource) |---|---| | `final https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#mediaSource()` The wrapped child `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource`. | |

| ### 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.CompositeMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/CompositeMediaSource) |---|---| | `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. | | `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. | |
| From [androidx.media3.exoplayer.source.MediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource) |---|---| | `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 /> | |
| From [androidx.media3.exoplayer.source.WrappingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource) |---|---| | `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#disableChildSource()()` Disables the child source. | | `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#enableChildSource()()` Enables the child source. | | `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#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://developer.android.com/reference/androidx/media3/common/MediaItem` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#getMediaItem()()` Returns the whose media is provided by the source. | | `@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/WrappingMediaSource#getMediaPeriodIdForChildMediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)( 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 wrapping source corresponding to the specified `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId` in a child source. | | `final @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/WrappingMediaSource#getMediaPeriodIdForChildMediaPeriodId(java.lang.Void,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)( https://developer.android.com/reference/java/lang/Void.html 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/WrappingMediaSource#getMediaTimeForChildMediaTime(long,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)( 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 wrapping source corresponding to the specified media time in the `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` of the child source. | | `final long` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#getMediaTimeForChildMediaTime(java.lang.Void,long,androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)( https://developer.android.com/reference/java/lang/Void.html 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/WrappingMediaSource#getWindowIndexForChildWindowIndex(int)(int windowIndex)` Returns the window index in the wrapping source corresponding to the specified window index in a child source. | | `final int` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#getWindowIndexForChildWindowIndex(java.lang.Void,int)(https://developer.android.com/reference/java/lang/Void.html childSourceId, int windowIndex)` Returns the window index in the composite source corresponding to the specified window index in a child source. | | `boolean` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#isSingleWindow()()` Returns true if the media source is guaranteed to never have zero or more than one window. | | `final void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#onChildSourceInfoRefreshed(java.lang.Void,androidx.media3.exoplayer.source.MediaSource,androidx.media3.common.Timeline)( https://developer.android.com/reference/java/lang/Void.html 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/WrappingMediaSource#prepareChildSource()()` Prepares the wrapped child source. | | `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/source/WrappingMediaSource#prepareSourceInternal()()` 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/WrappingMediaSource#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/WrappingMediaSource#releaseChildSource()()` Releases the child source. | |

## Public constructors

### ClippingMediaSource

```
public [ClippingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#ClippingMediaSource(androidx.media3.exoplayer.source.MediaSource,long))(MediaSource mediaSource, long durationUs)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.Builder` instead.

### ClippingMediaSource

```
public [ClippingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#ClippingMediaSource(androidx.media3.exoplayer.source.MediaSource,long,long))(
    MediaSource mediaSource,
    long startPositionUs,
    long endPositionUs
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.Builder` instead.

### ClippingMediaSource

```
public [ClippingMediaSource](https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource#ClippingMediaSource(androidx.media3.exoplayer.source.MediaSource,long,long,boolean,boolean,boolean))(
    MediaSource mediaSource,
    long startPositionUs,
    long endPositionUs,
    boolean enableInitialDiscontinuity,
    boolean allowDynamicClippingUpdates,
    boolean relativeToDefaultPosition
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/exoplayer/source/ClippingMediaSource.Builder` instead.

## Public methods

### canUpdateMediaItem

```
public boolean canUpdateMediaItem(MediaItem mediaItem)
```

Returns whether the 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.

This method can be overridden to change whether the `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the child source can be updated.

### createPeriod

```
public MediaPeriod createPeriod(
    MediaSource.MediaPeriodId id,
    Allocator allocator,
    long startPositionUs
)
```

Creates the requested `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.

This method typically forwards to the wrapped media source and optionally wraps the returned `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#createPeriod(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.exoplayer.upstream.Allocator,long)` |   |

### maybeThrowSourceInfoRefreshError

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

### releasePeriod

```
public void releasePeriod(MediaPeriod mediaPeriod)
```

Releases a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.

This method typically forwards to the wrapped media source and optionally unwraps the provided `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#releasePeriod(androidx.media3.exoplayer.source.MediaPeriod)` |   |

### updateMediaItem

```
public void updateMediaItem(MediaItem mediaItem)
```

Updates the for this source.

Should not be called directly from application code.

This method must be called on the playback thread and only if #canUpdateMediaItem returns true} for the new .

This method can be overridden to change how the `https://developer.android.com/reference/androidx/media3/common/MediaItem` of the child source is updated.

## Protected methods

### onChildSourceInfoRefreshed

```
protected void onChildSourceInfoRefreshed(Timeline newTimeline)
```

Called when the child source info has been refreshed.

This `https://developer.android.com/reference/androidx/media3/common/Timeline` can be amended if needed, for example using `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline`. The `https://developer.android.com/reference/androidx/media3/common/Timeline` for the wrapping source needs to be published with `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#refreshSourceInfo(androidx.media3.common.Timeline)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline` | The timeline of the child source. |

### releaseSourceInternal

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