# FakeMediaSource

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

*** ** * ** ***

<br />

```
@UnstableApi
public class FakeMediaSource 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.test.utils.FakeMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource) |

Known direct subclasses [FakeAdaptiveMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeAdaptiveMediaSource)

|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeAdaptiveMediaSource` | Fake `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` that provides a given timeline. |

*** ** * ** ***

Fake `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource` that provides a given timeline. Creating the period will return a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod` with a `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray` using the given `https://developer.android.com/reference/androidx/media3/common/Format`s.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` A builder for `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource` instances. |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.InitialTimeline extends https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline` A forwarding timeline to provide an initial timeline for fake multi window sources. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/common/MediaItem` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FAKE_MEDIA_ITEM()` The media item used by the fake media source. |

| ### Protected fields |
|---|---|
| `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html https://developer.android.com/reference/androidx/media3/common/Timeline` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#timeline()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource()()` Creates a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource` with a default `https://developer.android.com/reference/androidx/media3/test/utils/FakeTimeline`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.common.Format...)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline timeline, Format[] formats)` Creates a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource`. |
| `[FakeMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.common.Format...))( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline timeline, https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager drmSessionManager, Format[] formats )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` instead (or `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,long[],androidx.media3.exoplayer.source.TrackGroupArray)` for subclasses of ` FakeMediaSource`). <br /> |
| `[FakeMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,androidx.media3.common.Format...))( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline timeline, https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager drmSessionManager, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod.TrackDataFactory trackDataFactory, Format[] formats )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` instead (or `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,long[],androidx.media3.exoplayer.source.TrackGroupArray)` for subclasses of ` FakeMediaSource`). <br /> |
| `[FakeMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,androidx.media3.exoplayer.source.TrackGroupArray))( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline timeline, https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager drmSessionManager, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod.TrackDataFactory trackDataFactory, https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray trackGroupArray )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` instead (or `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,long[],androidx.media3.exoplayer.source.TrackGroupArray)` for subclasses of ` FakeMediaSource`). <br /> |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,long[],androidx.media3.exoplayer.source.TrackGroupArray)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline timeline, https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager drmSessionManager, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod.TrackDataFactory trackDataFactory, @https://developer.android.com/reference/androidx/annotation/Nullable long[] syncSampleTimesUs, https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray trackGroupArray )` Creates a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource`. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#assertMediaPeriodCreated(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId mediaPeriodId)` Assert that a media period for the given id has been created. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#assertReleased()()` Assert that the source and all periods have been released. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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`. |
| `static https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#createWithWindowId(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html windowId)` Convenience method to create a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource` with the given window id. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId>` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#getCreatedMediaPeriods()()` Returns a list of `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`s, with one element for each created media period. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Timeline` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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/exoplayer/source/MediaPeriod` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#getLastCreatedActiveMediaPeriod()()` Returns the last created active `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`. |
| `https://developer.android.com/reference/androidx/media3/common/MediaItem` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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/test/utils/FakeMediaSource#isPrepared()()` Returns whether the source is currently prepared. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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/test/utils/FakeMediaSource#maybeThrowSourceInfoRefreshError()()` Throws any pending error encountered while loading or refreshing source information. |
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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)`. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#releasePeriod(androidx.media3.exoplayer.source.MediaPeriod)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod mediaPeriod)` Releases the period. |
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setAllowPreparation(boolean)(boolean allowPreparation)` Sets whether the next call to `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)` is allowed to finish. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setCanUpdateMediaItems(boolean)(boolean canUpdateMediaItems)` Sets whether the source allows to update its `https://developer.android.com/reference/androidx/media3/common/MediaItem` via `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#updateMediaItem(androidx.media3.common.MediaItem)`. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setNewSourceInfo(androidx.media3.common.Timeline)(https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline)` Sets a new timeline. |
| `synchronized void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setNewSourceInfo(androidx.media3.common.Timeline,boolean)(https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline, boolean sendManifestLoadEvents)` Sets a new timeline. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setPeriodDefersOnPreparedCallback(boolean)( boolean periodDefersOnPreparedCallback )` Sets whether the created `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod` should defer to call `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod.Callback#onPrepared(androidx.media3.exoplayer.source.MediaPeriod)`. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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 methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/RequiresNonNull.html(value = "this.timeline") https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#createMediaPeriod(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.exoplayer.source.TrackGroupArray,androidx.media3.exoplayer.upstream.Allocator,androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.exoplayer.drm.DrmSessionEventListener.EventDispatcher,androidx.media3.datasource.TransferListener)( https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId id, https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray trackGroupArray, https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator allocator, https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher, https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager drmSessionManager, https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher drmEventDispatcher, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/datasource/TransferListener transferListener )` Creates a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` for this media 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/test/utils/FakeMediaSource#getTimeline()()` |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#releaseMediaPeriod(androidx.media3.exoplayer.source.MediaPeriod)(https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod mediaPeriod)` Releases a media period created by `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#createMediaPeriod(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.exoplayer.source.TrackGroupArray,androidx.media3.exoplayer.upstream.Allocator,androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.exoplayer.drm.DrmSessionEventListener.EventDispatcher,androidx.media3.datasource.TransferListener)`. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#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`.
`void` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#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/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`.
`void` `https://developer.android.com/reference/androidx/media3/exoplayer/source/BaseMediaSource#enableInternal()()`

Enables the source, see `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource#enable(androidx.media3.exoplayer.source.MediaSource.MediaSourceCaller)`.
`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) `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 />

## Constants

### FAKE_MEDIA_ITEM

```
public static final MediaItem FAKE_MEDIA_ITEM
```

The media item used by the fake media source.

## Protected fields

### timeline

```
@MonotonicNonNull
protected @MonotonicNonNull Timeline timeline
```

## Public constructors

### FakeMediaSource

```
public FakeMediaSource()
```

Creates a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource` with a default `https://developer.android.com/reference/androidx/media3/test/utils/FakeTimeline`.

Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` to create a more configured instance.

### FakeMediaSource

```
public FakeMediaSource(@Nullable Timeline timeline, Format[] formats)
```

Creates a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource`. This media source creates `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod`s with a `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray` using the given `https://developer.android.com/reference/androidx/media3/common/Format`s. The provided `https://developer.android.com/reference/androidx/media3/common/Timeline` may be null to prevent an immediate source info refresh message when preparing the media source. It can be manually set later using `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setNewSourceInfo(androidx.media3.common.Timeline)`.

Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` to create a more configured instance.

### FakeMediaSource

```
public [FakeMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.common.Format...))(
    @Nullable Timeline timeline,
    DrmSessionManager drmSessionManager,
    Format[] formats
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` instead (or `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,long[],androidx.media3.exoplayer.source.TrackGroupArray)` for subclasses of ` FakeMediaSource`).

### FakeMediaSource

```
public [FakeMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,androidx.media3.common.Format...))(
    @Nullable Timeline timeline,
    DrmSessionManager drmSessionManager,
    @Nullable FakeMediaPeriod.TrackDataFactory trackDataFactory,
    Format[] formats
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` instead (or `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,long[],androidx.media3.exoplayer.source.TrackGroupArray)` for subclasses of ` FakeMediaSource`).

### FakeMediaSource

```
public [FakeMediaSource](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,androidx.media3.exoplayer.source.TrackGroupArray))(
    @Nullable Timeline timeline,
    DrmSessionManager drmSessionManager,
    @Nullable FakeMediaPeriod.TrackDataFactory trackDataFactory,
    TrackGroupArray trackGroupArray
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.Builder` instead (or `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#FakeMediaSource(androidx.media3.common.Timeline,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.test.utils.FakeMediaPeriod.TrackDataFactory,long[],androidx.media3.exoplayer.source.TrackGroupArray)` for subclasses of ` FakeMediaSource`).

## Protected constructors

### FakeMediaSource

```
protected FakeMediaSource(
    @Nullable Timeline timeline,
    DrmSessionManager drmSessionManager,
    @Nullable FakeMediaPeriod.TrackDataFactory trackDataFactory,
    @Nullable long[] syncSampleTimesUs,
    TrackGroupArray trackGroupArray
)
```

Creates a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource`. This media source creates `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod`s with the provided `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray`, `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager`, `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod.TrackDataFactory`, and `syncSampleTimesUs`. The provided `https://developer.android.com/reference/androidx/media3/common/Timeline` may be null to prevent an immediate source info refresh message when preparing the media source. It can be manually set later using `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setNewSourceInfo(androidx.media3.common.Timeline)`.

## Public methods

### assertMediaPeriodCreated

```
public void assertMediaPeriodCreated(MediaSource.MediaPeriodId mediaPeriodId)
```

Assert that a media period for the given id has been created.

### assertReleased

```
public void assertReleased()
```

Assert that the source and all periods have been released.

### canUpdateMediaItem

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

Returns whether the `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem` | The new `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |

| Returns |
|---|---|
| `boolean` | Whether the source can be updated using this item. |

### createPeriod

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

Returns a new `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId id` | The identifier of the period. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator allocator` | An `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator` from which to obtain media buffer allocations. |
| `long startPositionUs` | The expected start position, in microseconds. |

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

### createWithWindowId

```
public static FakeMediaSource createWithWindowId(Object windowId)
```

Convenience method to create a `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource` with the given window id.

### getCreatedMediaPeriods

```
public List<MediaSource.MediaPeriodId> getCreatedMediaPeriods()
```

Returns a list of `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId`s, with one element for each created media period.

### getInitialTimeline

```
public @Nullable Timeline 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.

Should not be called directly from application code.

The initial timeline must use the same uids for windows and periods that the real timeline will use. It also must provide windows which are marked as dynamic to indicate that the window is expected to change when the real timeline arrives.

Any media source which has multiple windows should typically provide such an initial timeline to make sure the player reports the correct number of windows immediately.

This method must be called on the application thread.

### getLastCreatedActiveMediaPeriod

```
public MediaPeriod getLastCreatedActiveMediaPeriod()
```

Returns the last created active `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod`.

Must only be called if the source has created at least one period and it hasn't been released.

### getMediaItem

```
public MediaItem getMediaItem()
```

Returns the `https://developer.android.com/reference/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.

### isPrepared

```
public boolean isPrepared()
```

Returns whether the source is currently prepared.

### isSingleWindow

```
public boolean isSingleWindow()
```

Returns true if the media source is guaranteed to never have zero or more than one window.

Should not be called directly from application code.

The default implementation returns `true`.

This method must be called on the application thread.

| Returns |
|---|---|
| `boolean` | true if the source has exactly one window. |

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

### prepareSourceInternal

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

### releasePeriod

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

Releases the period.

Should not be called directly from application code.

This method must be called on the playback thread.

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

### setAllowPreparation

```
synchronized public void setAllowPreparation(boolean allowPreparation)
```

Sets whether the next call to `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)` is allowed to finish. If not allowed, a later call to this method with `allowPreparation` set to true will finish the preparation.

| Parameters |
|---|---|
| `boolean allowPreparation` | Whether preparation is allowed to finish. |

### setCanUpdateMediaItems

```
public void setCanUpdateMediaItems(boolean canUpdateMediaItems)
```

Sets whether the source allows to update its `https://developer.android.com/reference/androidx/media3/common/MediaItem` via `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#updateMediaItem(androidx.media3.common.MediaItem)`.

| Parameters |
|---|---|
| `boolean canUpdateMediaItems` | Whether a `https://developer.android.com/reference/androidx/media3/common/MediaItem` update is possible. |

### setNewSourceInfo

```
public void setNewSourceInfo(Timeline newTimeline)
```

Sets a new timeline. If the source is already prepared, this triggers a source info refresh message being sent to the listener.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline` | The new `https://developer.android.com/reference/androidx/media3/common/Timeline`. |

### setNewSourceInfo

```
synchronized public void setNewSourceInfo(Timeline newTimeline, boolean sendManifestLoadEvents)
```

Sets a new timeline. If the source is already prepared, this triggers a source info refresh message being sent to the listener.

Must only be called if preparation is `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#setAllowPreparation(boolean)`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline newTimeline` | The new `https://developer.android.com/reference/androidx/media3/common/Timeline`. |
| `boolean sendManifestLoadEvents` | Whether to treat this as a manifest refresh and send manifest load events to listeners. |

### setPeriodDefersOnPreparedCallback

```
public void setPeriodDefersOnPreparedCallback(
    boolean periodDefersOnPreparedCallback
)
```

Sets whether the created `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod` should defer to call `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod.Callback#onPrepared(androidx.media3.exoplayer.source.MediaPeriod)`. If set to true, `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod.Callback#onPrepared(androidx.media3.exoplayer.source.MediaPeriod)` should be called only after `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaPeriod#setPreparationComplete()` has been called, otherwise the preparation completes immediately.

### updateMediaItem

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

Updates the `https://developer.android.com/reference/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/androidx/media3/exoplayer/source/MediaSource#canUpdateMediaItem(androidx.media3.common.MediaItem)` returns `true` for the new `https://developer.android.com/reference/androidx/media3/common/MediaItem`.

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

## Protected methods

### createMediaPeriod

```
@RequiresNonNull(value = "this.timeline")
protected MediaPeriod createMediaPeriod(
    MediaSource.MediaPeriodId id,
    TrackGroupArray trackGroupArray,
    Allocator allocator,
    MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher,
    DrmSessionManager drmSessionManager,
    DrmSessionEventListener.EventDispatcher drmEventDispatcher,
    @Nullable TransferListener transferListener
)
```

Creates a `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaPeriod` for this media source.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSource.MediaPeriodId id` | The identifier of the period. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray trackGroupArray` | The `https://developer.android.com/reference/androidx/media3/exoplayer/source/TrackGroupArray` supported by the media period. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator allocator` | An `https://developer.android.com/reference/androidx/media3/exoplayer/upstream/Allocator` from which to obtain media buffer allocations. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher` | An `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` to dispatch media source events. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager drmSessionManager` | A `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionManager` to allow DRM interactions. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/drm/DrmSessionEventListener.EventDispatcher drmEventDispatcher` | An `https://developer.android.com/reference/androidx/media3/exoplayer/source/MediaSourceEventListener.EventDispatcher` to dispatch DRM events. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/datasource/TransferListener transferListener` | The transfer listener which should be informed of any data transfers. May be null if no listener is available. |

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

### getTimeline

```
protected @Nullable Timeline getTimeline()
```

### releaseMediaPeriod

```
protected void releaseMediaPeriod(MediaPeriod mediaPeriod)
```

Releases a media period created by `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource#createMediaPeriod(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId,androidx.media3.exoplayer.source.TrackGroupArray,androidx.media3.exoplayer.upstream.Allocator,androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher,androidx.media3.exoplayer.drm.DrmSessionManager,androidx.media3.exoplayer.drm.DrmSessionEventListener.EventDispatcher,androidx.media3.datasource.TransferListener)`.

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