docs/doc/reference/com/google/android/exoplayer2/source/BaseMediaSource.html
Package com.google.android.exoplayer2.source
All Implemented Interfaces:MediaSourceDirect Known Subclasses:CompositeMediaSource, DashMediaSource, FakeMediaSource, HlsMediaSource, ProgressiveMediaSource, RtspMediaSource, ServerSideAdInsertionMediaSource, SilenceMediaSource, SingleSampleMediaSource, SsMediaSource
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public abstract classBaseMediaSourceextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[MediaSource](MediaSource.html "interface in com.google.android.exoplayer2.source")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
Base MediaSource implementation to handle parallel reuse and to keep a list of MediaSourceEventListeners.
Whenever an implementing subclass needs to provide a new timeline, it must call refreshSourceInfo(Timeline) to notify all listeners.
-
MediaSource.Factory, MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller
Constructors | Constructor | Description |
| --- | --- |
| BaseMediaSource() |
Deprecated.
|
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | addDrmEventListener(Handler handler, DrmSessionEventListener eventListener) |
Deprecated.
Adds a DrmSessionEventListener to the list of listeners which are notified of DRM events for this media source.
|
| void | addEventListener(Handler handler, MediaSourceEventListener eventListener) |
Deprecated.
Adds a MediaSourceEventListener to the list of listeners which are notified of media source events.
|
| protected DrmSessionEventListener.EventDispatcher | createDrmEventDispatcher(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId) |
Deprecated.
Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaSource.MediaPeriodId.
|
| protected DrmSessionEventListener.EventDispatcher | createDrmEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId) |
Deprecated.
Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaSource.MediaPeriodId
|
| protected MediaSourceEventListener.EventDispatcher | createEventDispatcher(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId) |
Deprecated.
Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaSource.MediaPeriodId.
|
| protected MediaSourceEventListener.EventDispatcher | createEventDispatcher(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs) |
Deprecated.
Use createEventDispatcher(int, MediaPeriodId) instead.
|
| protected MediaSourceEventListener.EventDispatcher | createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId) |
Deprecated.
Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaSource.MediaPeriodId.
|
| protected MediaSourceEventListener.EventDispatcher | createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs) |
Deprecated.
Use createEventDispatcher(MediaPeriodId) instead.
|
| void | disable(MediaSource.MediaSourceCaller caller) |
Deprecated.
Disables the source for the creation of MediaPeriods.
|
| protected void | disableInternal() |
Deprecated.
Disables the source, see disable(MediaSourceCaller).
|
| void | enable(MediaSource.MediaSourceCaller caller) |
Deprecated.
Enables the source for the creation of MediaPeriods.
|
| protected void | enableInternal() |
Deprecated.
Enables the source, see enable(MediaSourceCaller).
|
| protected PlayerId | getPlayerId() |
Deprecated.
Returns the PlayerId of the player using this media source.
|
| protected boolean | isEnabled() |
Deprecated.
Returns whether the source is enabled.
|
| void | prepareSource(MediaSource.MediaSourceCaller caller, TransferListener mediaTransferListener) |
Deprecated.
|
| void | prepareSource(MediaSource.MediaSourceCaller caller, TransferListener mediaTransferListener, PlayerId playerId) |
Deprecated.
Registers a MediaSource.MediaSourceCaller.
|
| protected abstract void | prepareSourceInternal(TransferListener mediaTransferListener) |
Deprecated.
Starts source preparation and enables the source, see prepareSource(MediaSourceCaller, TransferListener, PlayerId).
|
| protected void | refreshSourceInfo(Timeline timeline) |
Deprecated.
Updates timeline and manifest and notifies all listeners of the update.
|
| void | releaseSource(MediaSource.MediaSourceCaller caller) |
Deprecated.
Unregisters a caller, and disables and releases the source if no longer required.
|
| protected abstract void | releaseSourceInternal() |
Deprecated.
Releases the source, see releaseSource(MediaSourceCaller).
|
| void | removeDrmEventListener(DrmSessionEventListener eventListener) |
Deprecated.
Removes a DrmSessionEventListener from the list of listeners which are notified of DRM events for this media source.
|
| void | removeEventListener(MediaSourceEventListener eventListener) |
Deprecated.
Removes a MediaSourceEventListener from the list of listeners which are notified of media source events.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
createPeriod, getInitialTimeline, getMediaItem, isSingleWindow, maybeThrowSourceInfoRefreshError, releasePeriod
-
public BaseMediaSource()
Deprecated.
-
protected abstract void prepareSourceInternal(@Nullable[TransferListener](../upstream/TransferListener.html "interface in com.google.android.exoplayer2.upstream")mediaTransferListener)
Deprecated.
Starts source preparation and enables the source, see prepareSource(MediaSourceCaller, TransferListener, PlayerId). This method is called at most once until the next call to releaseSourceInternal().
Parameters: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.
-
protected void enableInternal()
Deprecated.
Enables the source, see enable(MediaSourceCaller).
-
protected void disableInternal()
Deprecated.
Disables the source, see disable(MediaSourceCaller).
-
protected abstract void releaseSourceInternal()
Deprecated.
Releases the source, see releaseSource(MediaSourceCaller). This method is called exactly once after each call to prepareSourceInternal(TransferListener).
-
protected final void refreshSourceInfo([Timeline](../Timeline.html "class in com.google.android.exoplayer2")timeline)
Deprecated.
Updates timeline and manifest and notifies all listeners of the update.
Parameters:timeline - The new Timeline.
-
protected final[MediaSourceEventListener.EventDispatcher](MediaSourceEventListener.EventDispatcher.html "class in com.google.android.exoplayer2.source")createEventDispatcher(@Nullable[MediaSource.MediaPeriodId](MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId)
Deprecated.
Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaSource.MediaPeriodId.
Parameters:mediaPeriodId - The MediaSource.MediaPeriodId to be reported with the events. May be null, if the events do not belong to a specific media period.Returns:An event dispatcher with pre-configured media period id.
-
protected final[MediaSourceEventListener.EventDispatcher](MediaSourceEventListener.EventDispatcher.html "class in com.google.android.exoplayer2.source")createEventDispatcher(int windowIndex,
@Nullable[MediaSource.MediaPeriodId](MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId)
Deprecated.
Returns a MediaSourceEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaSource.MediaPeriodId.
Parameters:windowIndex - The timeline window index to be reported with the events.mediaPeriodId - The MediaSource.MediaPeriodId to be reported with the events. May be null, if the events do not belong to a specific media period.Returns:An event dispatcher with pre-configured media period id.
-
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")protected final[MediaSourceEventListener.EventDispatcher](MediaSourceEventListener.EventDispatcher.html "class in com.google.android.exoplayer2.source")createEventDispatcher([MediaSource.MediaPeriodId](MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId,
long mediaTimeOffsetMs)
Deprecated.
Use createEventDispatcher(MediaPeriodId) instead.
Note: The mediaTimeOffsetMs passed to this method is ignored and not added to media times in any way.
-
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")protected final[MediaSourceEventListener.EventDispatcher](MediaSourceEventListener.EventDispatcher.html "class in com.google.android.exoplayer2.source")createEventDispatcher(int windowIndex,
@Nullable[MediaSource.MediaPeriodId](MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId,
long mediaTimeOffsetMs)
Deprecated.
Use createEventDispatcher(int, MediaPeriodId) instead.
Note: The mediaTimeOffsetMs passed to this method is ignored and not added to media times in any way.
-
protected final[DrmSessionEventListener.EventDispatcher](../drm/DrmSessionEventListener.EventDispatcher.html "class in com.google.android.exoplayer2.drm")createDrmEventDispatcher(@Nullable[MediaSource.MediaPeriodId](MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId)
Deprecated.
Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified MediaSource.MediaPeriodId
Parameters:mediaPeriodId - The MediaSource.MediaPeriodId to be reported with the events. May be null, if the events do not belong to a specific media period.Returns:An event dispatcher with pre-configured media period id.
-
protected final[DrmSessionEventListener.EventDispatcher](../drm/DrmSessionEventListener.EventDispatcher.html "class in com.google.android.exoplayer2.drm")createDrmEventDispatcher(int windowIndex,
@Nullable[MediaSource.MediaPeriodId](MediaSource.MediaPeriodId.html "class in com.google.android.exoplayer2.source")mediaPeriodId)
Deprecated.
Returns a DrmSessionEventListener.EventDispatcher which dispatches all events to the registered listeners with the specified window index and MediaSource.MediaPeriodId.
Parameters:windowIndex - The timeline window index to be reported with the events.mediaPeriodId - The MediaSource.MediaPeriodId to be reported with the events. May be null, if the events do not belong to a specific media period.Returns:An event dispatcher with pre-configured media period id and time offset.
-
protected final boolean isEnabled()
Deprecated.
Returns whether the source is enabled.
-
protected final[PlayerId](../analytics/PlayerId.html "class in com.google.android.exoplayer2.analytics")getPlayerId()
Deprecated.
Returns the PlayerId of the player using this media source.
Must only be used when the media source is prepared.
-
public final void addEventListener([Handler](https://developer.android.com/reference/android/os/Handler.html "class or interface in android.os")handler,[MediaSourceEventListener](MediaSourceEventListener.html "interface in com.google.android.exoplayer2.source")eventListener)
Deprecated.
Description copied from interface: MediaSource
Adds a MediaSourceEventListener to the list of listeners which are notified of media source events.
Should not be called directly from application code.
This method must be called on the playback thread.
Specified by:addEventListener in interface MediaSourceParameters:handler - A handler on the which listener events will be posted.eventListener - The listener to be added.
-
public final void removeEventListener([MediaSourceEventListener](MediaSourceEventListener.html "interface in com.google.android.exoplayer2.source")eventListener)
Deprecated.
Description copied from interface: MediaSource
Removes a MediaSourceEventListener from the list of listeners which are notified of media source events.
Should not be called directly from application code.
This method must be called on the playback thread.
Specified by:removeEventListener in interface MediaSourceParameters:eventListener - The listener to be removed.
-
public final void addDrmEventListener([Handler](https://developer.android.com/reference/android/os/Handler.html "class or interface in android.os")handler,[DrmSessionEventListener](../drm/DrmSessionEventListener.html "interface in com.google.android.exoplayer2.drm")eventListener)
Deprecated.
Description copied from interface: MediaSource
Adds a DrmSessionEventListener to the list of listeners which are notified of DRM events for this media source.
Should not be called directly from application code.
This method must be called on the playback thread.
Specified by:addDrmEventListener in interface MediaSourceParameters:handler - A handler on the which listener events will be posted.eventListener - The listener to be added.
-
public final void removeDrmEventListener([DrmSessionEventListener](../drm/DrmSessionEventListener.html "interface in com.google.android.exoplayer2.drm")eventListener)
Deprecated.
Description copied from interface: MediaSource
Removes a DrmSessionEventListener from the list of listeners which are notified of DRM events for this media source.
Should not be called directly from application code.
This method must be called on the playback thread.
Specified by:removeDrmEventListener in interface MediaSourceParameters:eventListener - The listener to be removed.
-
public final void prepareSource([MediaSource.MediaSourceCaller](MediaSource.MediaSourceCaller.html "interface in com.google.android.exoplayer2.source")caller,
@Nullable[TransferListener](../upstream/TransferListener.html "interface in com.google.android.exoplayer2.upstream")mediaTransferListener)
Deprecated.
Specified by:prepareSource in interface MediaSource
-
public final void prepareSource([MediaSource.MediaSourceCaller](MediaSource.MediaSourceCaller.html "interface in com.google.android.exoplayer2.source")caller,
@Nullable[TransferListener](../upstream/TransferListener.html "interface in com.google.android.exoplayer2.upstream")mediaTransferListener,[PlayerId](../analytics/PlayerId.html "class in com.google.android.exoplayer2.analytics")playerId)
Deprecated.
Description copied from interface: MediaSource
Registers a MediaSource.MediaSourceCaller. Starts source preparation if needed and enables the source for the creation of MediaPerods.
Should not be called directly from application code.
MediaSource.MediaSourceCaller.onSourceInfoRefreshed(MediaSource, Timeline) will be called once the source has a Timeline.
For each call to this method, a call to MediaSource.releaseSource(MediaSourceCaller) is needed to remove the caller and to release the source if no longer required.
This method must be called on the playback thread.
Specified by:prepareSource in interface MediaSourceParameters:caller - The MediaSource.MediaSourceCaller to be registered.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 be only informed of transfers related to the media loads and not of auxiliary loads for manifests and other data.playerId - The PlayerId of the player using this media source.
-
public final void enable([MediaSource.MediaSourceCaller](MediaSource.MediaSourceCaller.html "interface in com.google.android.exoplayer2.source")caller)
Deprecated.
Description copied from interface: MediaSource
Enables the source for the creation of MediaPeriods.
Should not be called directly from application code.
This method must be called on the playback thread and only after MediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId).
Specified by:enable in interface MediaSourceParameters:caller - The MediaSource.MediaSourceCaller enabling the source.
-
public final void disable([MediaSource.MediaSourceCaller](MediaSource.MediaSourceCaller.html "interface in com.google.android.exoplayer2.source")caller)
Deprecated.
Description copied from interface: MediaSource
Disables the source for the creation of MediaPeriods. The implementation should not hold onto limited resources used for the creation of media periods.
Should not be called directly from application code.
This method must be called on the playback thread and only after all MediaPeriods previously created by MediaSource.createPeriod(MediaPeriodId, Allocator, long) have been released by MediaSource.releasePeriod(MediaPeriod).
Specified by:disable in interface MediaSourceParameters:caller - The MediaSource.MediaSourceCaller disabling the source.
-
public final void releaseSource([MediaSource.MediaSourceCaller](MediaSource.MediaSourceCaller.html "interface in com.google.android.exoplayer2.source")caller)
Deprecated.
Description copied from interface: MediaSource
Unregisters a caller, and disables and releases the source if no longer required.
Should not be called directly from application code.
This method must be called on the playback thread and only if all created MediaPeriods have been released by MediaSource.releasePeriod(MediaPeriod).
Specified by:releaseSource in interface MediaSourceParameters:caller - The MediaSource.MediaSourceCaller to be unregistered.