Class BaseMediaSource
- java.lang.Object
-
- com.google.android.exoplayer2.source.BaseMediaSource
-
- All Implemented Interfaces:
MediaSource
- Direct Known Subclasses:
CompositeMediaSource
,DashMediaSource
,FakeMediaSource
,HlsMediaSource
,ProgressiveMediaSource
,RtspMediaSource
,ServerSideAdInsertionMediaSource
,SilenceMediaSource
,SingleSampleMediaSource
,SsMediaSource
@Deprecated public abstract class BaseMediaSource extends Object implements MediaSource
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.BaseMediaSource
implementation to handle parallel reuse and to keep a list ofMediaSourceEventListener
s.Whenever an implementing subclass needs to provide a new timeline, it must call
refreshSourceInfo(Timeline)
to notify all listeners.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.MediaSource
MediaSource.Factory, MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller
-
-
Constructor Summary
Constructors Constructor Description BaseMediaSource()
Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDrmEventListener(Handler handler, DrmSessionEventListener eventListener)
Deprecated.Adds aDrmSessionEventListener
to the list of listeners which are notified of DRM events for this media source.void
addEventListener(Handler handler, MediaSourceEventListener eventListener)
Deprecated.Adds aMediaSourceEventListener
to the list of listeners which are notified of media source events.protected DrmSessionEventListener.EventDispatcher
createDrmEventDispatcher(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aDrmSessionEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specified window index andMediaSource.MediaPeriodId
.protected DrmSessionEventListener.EventDispatcher
createDrmEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aDrmSessionEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specifiedMediaSource.MediaPeriodId
protected MediaSourceEventListener.EventDispatcher
createEventDispatcher(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aMediaSourceEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specified window index andMediaSource.MediaPeriodId
.protected MediaSourceEventListener.EventDispatcher
createEventDispatcher(int windowIndex, MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs)
Deprecated.UsecreateEventDispatcher(int, MediaPeriodId)
instead.protected MediaSourceEventListener.EventDispatcher
createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aMediaSourceEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specifiedMediaSource.MediaPeriodId
.protected MediaSourceEventListener.EventDispatcher
createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs)
Deprecated.UsecreateEventDispatcher(MediaPeriodId)
instead.void
disable(MediaSource.MediaSourceCaller caller)
Deprecated.Disables the source for the creation ofMediaPeriods
.protected void
disableInternal()
Deprecated.Disables the source, seedisable(MediaSourceCaller)
.void
enable(MediaSource.MediaSourceCaller caller)
Deprecated.Enables the source for the creation ofMediaPeriods
.protected void
enableInternal()
Deprecated.Enables the source, seeenable(MediaSourceCaller)
.protected PlayerId
getPlayerId()
Deprecated.Returns thePlayerId
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 aMediaSource.MediaSourceCaller
.protected abstract void
prepareSourceInternal(TransferListener mediaTransferListener)
Deprecated.Starts source preparation and enables the source, seeprepareSource(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, seereleaseSource(MediaSourceCaller)
.void
removeDrmEventListener(DrmSessionEventListener eventListener)
Deprecated.Removes aDrmSessionEventListener
from the list of listeners which are notified of DRM events for this media source.void
removeEventListener(MediaSourceEventListener eventListener)
Deprecated.Removes aMediaSourceEventListener
from the list of listeners which are notified of media source events.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.android.exoplayer2.source.MediaSource
createPeriod, getInitialTimeline, getMediaItem, isSingleWindow, maybeThrowSourceInfoRefreshError, releasePeriod
-
-
-
-
Method Detail
-
prepareSourceInternal
protected abstract void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)
Deprecated.Starts source preparation and enables the source, seeprepareSource(MediaSourceCaller, TransferListener, PlayerId)
. This method is called at most once until the next call toreleaseSourceInternal()
.- 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.
-
enableInternal
protected void enableInternal()
Deprecated.Enables the source, seeenable(MediaSourceCaller)
.
-
disableInternal
protected void disableInternal()
Deprecated.Disables the source, seedisable(MediaSourceCaller)
.
-
releaseSourceInternal
protected abstract void releaseSourceInternal()
Deprecated.Releases the source, seereleaseSource(MediaSourceCaller)
. This method is called exactly once after each call toprepareSourceInternal(TransferListener)
.
-
refreshSourceInfo
protected final void refreshSourceInfo(Timeline timeline)
Deprecated.Updates timeline and manifest and notifies all listeners of the update.- Parameters:
timeline
- The newTimeline
.
-
createEventDispatcher
protected final MediaSourceEventListener.EventDispatcher createEventDispatcher(@Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aMediaSourceEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specifiedMediaSource.MediaPeriodId
.- Parameters:
mediaPeriodId
- TheMediaSource.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.
-
createEventDispatcher
protected final MediaSourceEventListener.EventDispatcher createEventDispatcher(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aMediaSourceEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specified window index andMediaSource.MediaPeriodId
.- Parameters:
windowIndex
- The timeline window index to be reported with the events.mediaPeriodId
- TheMediaSource.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.
-
createEventDispatcher
@Deprecated protected final MediaSourceEventListener.EventDispatcher createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs)
Deprecated.UsecreateEventDispatcher(MediaPeriodId)
instead.Note: ThemediaTimeOffsetMs
passed to this method is ignored and not added to media times in any way.
-
createEventDispatcher
@Deprecated protected final MediaSourceEventListener.EventDispatcher createEventDispatcher(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs)
Deprecated.UsecreateEventDispatcher(int, MediaPeriodId)
instead.Note: ThemediaTimeOffsetMs
passed to this method is ignored and not added to media times in any way.
-
createDrmEventDispatcher
protected final DrmSessionEventListener.EventDispatcher createDrmEventDispatcher(@Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aDrmSessionEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specifiedMediaSource.MediaPeriodId
- Parameters:
mediaPeriodId
- TheMediaSource.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.
-
createDrmEventDispatcher
protected final DrmSessionEventListener.EventDispatcher createDrmEventDispatcher(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns aDrmSessionEventListener.EventDispatcher
which dispatches all events to the registered listeners with the specified window index andMediaSource.MediaPeriodId
.- Parameters:
windowIndex
- The timeline window index to be reported with the events.mediaPeriodId
- TheMediaSource.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.
-
isEnabled
protected final boolean isEnabled()
Deprecated.Returns whether the source is enabled.
-
getPlayerId
protected final PlayerId getPlayerId()
Deprecated.
-
addEventListener
public final void addEventListener(Handler handler, MediaSourceEventListener eventListener)
Deprecated.Description copied from interface:MediaSource
Adds aMediaSourceEventListener
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 interfaceMediaSource
- Parameters:
handler
- A handler on the which listener events will be posted.eventListener
- The listener to be added.
-
removeEventListener
public final void removeEventListener(MediaSourceEventListener eventListener)
Deprecated.Description copied from interface:MediaSource
Removes aMediaSourceEventListener
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 interfaceMediaSource
- Parameters:
eventListener
- The listener to be removed.
-
addDrmEventListener
public final void addDrmEventListener(Handler handler, DrmSessionEventListener eventListener)
Deprecated.Description copied from interface:MediaSource
Adds aDrmSessionEventListener
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 interfaceMediaSource
- Parameters:
handler
- A handler on the which listener events will be posted.eventListener
- The listener to be added.
-
removeDrmEventListener
public final void removeDrmEventListener(DrmSessionEventListener eventListener)
Deprecated.Description copied from interface:MediaSource
Removes aDrmSessionEventListener
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 interfaceMediaSource
- Parameters:
eventListener
- The listener to be removed.
-
prepareSource
public final void prepareSource(MediaSource.MediaSourceCaller caller, @Nullable TransferListener mediaTransferListener)
Deprecated.- Specified by:
prepareSource
in interfaceMediaSource
-
prepareSource
public final void prepareSource(MediaSource.MediaSourceCaller caller, @Nullable TransferListener mediaTransferListener, PlayerId playerId)
Deprecated.Description copied from interface:MediaSource
Registers aMediaSource.MediaSourceCaller
. Starts source preparation if needed and enables the source for the creation ofMediaPerods
.Should not be called directly from application code.
MediaSource.MediaSourceCaller.onSourceInfoRefreshed(MediaSource, Timeline)
will be called once the source has aTimeline
.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 interfaceMediaSource
- Parameters:
caller
- TheMediaSource.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
- ThePlayerId
of the player using this media source.
-
enable
public final void enable(MediaSource.MediaSourceCaller caller)
Deprecated.Description copied from interface:MediaSource
Enables the source for the creation ofMediaPeriods
.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 interfaceMediaSource
- Parameters:
caller
- TheMediaSource.MediaSourceCaller
enabling the source.
-
disable
public final void disable(MediaSource.MediaSourceCaller caller)
Deprecated.Description copied from interface:MediaSource
Disables the source for the creation ofMediaPeriods
. 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 byMediaSource.createPeriod(MediaPeriodId, Allocator, long)
have been released byMediaSource.releasePeriod(MediaPeriod)
.- Specified by:
disable
in interfaceMediaSource
- Parameters:
caller
- TheMediaSource.MediaSourceCaller
disabling the source.
-
releaseSource
public final void releaseSource(MediaSource.MediaSourceCaller 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 byMediaSource.releasePeriod(MediaPeriod)
.- Specified by:
releaseSource
in interfaceMediaSource
- Parameters:
caller
- TheMediaSource.MediaSourceCaller
to be unregistered.
-
-