public abstract class BaseMediaSource extends java.lang.Object implements MediaSource
MediaSource implementation to handle parallel reuse and to keep a list of MediaSourceEventListeners.
Whenever an implementing subclass needs to provide a new timeline and/or manifest, it must
call refreshSourceInfo(Timeline, Object) to notify all listeners.
MediaSource.MediaPeriodId, MediaSource.SourceInfoRefreshListener| Constructor and Description |
|---|
BaseMediaSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(android.os.Handler handler,
MediaSourceEventListener eventListener)
Adds a
MediaSourceEventListener to the list of listeners which are notified of media
source events. |
protected MediaSourceEventListener.EventDispatcher |
createEventDispatcher(int windowIndex,
MediaSource.MediaPeriodId mediaPeriodId,
long mediaTimeOffsetMs)
Returns a
MediaSourceEventListener.EventDispatcher which dispatches all events to the
registered listeners with the specified window index, media period id and time offset. |
protected MediaSourceEventListener.EventDispatcher |
createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId)
Returns a
MediaSourceEventListener.EventDispatcher which dispatches all events to the
registered listeners with the specified media period id. |
protected MediaSourceEventListener.EventDispatcher |
createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId,
long mediaTimeOffsetMs)
Returns a
MediaSourceEventListener.EventDispatcher which dispatches all events to the
registered listeners with the specified media period id and time offset. |
void |
prepareSource(ExoPlayer player,
boolean isTopLevelSource,
MediaSource.SourceInfoRefreshListener listener)
Starts source preparation if not yet started, and adds a listener for timeline and/or manifest
updates.
|
protected abstract void |
prepareSourceInternal(ExoPlayer player,
boolean isTopLevelSource)
Starts source preparation.
|
protected void |
refreshSourceInfo(Timeline timeline,
java.lang.Object manifest)
Updates timeline and manifest and notifies all listeners of the update.
|
void |
releaseSource(MediaSource.SourceInfoRefreshListener listener)
Removes a listener for timeline and/or manifest updates and releases the source if no longer
required.
|
protected abstract void |
releaseSourceInternal()
Releases the source.
|
void |
removeEventListener(MediaSourceEventListener eventListener)
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, waitcreatePeriod, maybeThrowSourceInfoRefreshError, releasePeriodprotected abstract void prepareSourceInternal(ExoPlayer player, boolean isTopLevelSource)
releaseSourceInternal().player - The player for which this source is being prepared.isTopLevelSource - Whether this source has been passed directly to ExoPlayer.prepare(MediaSource) or ExoPlayer.prepare(MediaSource, boolean,
boolean).protected abstract void releaseSourceInternal()
prepareSourceInternal(ExoPlayer, boolean).protected final void refreshSourceInfo(Timeline timeline, @Nullable java.lang.Object manifest)
timeline - The new Timeline.manifest - The new manifest. May be null.protected final MediaSourceEventListener.EventDispatcher createEventDispatcher(@Nullable MediaSource.MediaPeriodId mediaPeriodId)
MediaSourceEventListener.EventDispatcher which dispatches all events to the
registered listeners with the specified media period id.mediaPeriodId - The MediaPeriodId to be reported with the events. May be null, if
the events do not belong to a specific media period.protected final MediaSourceEventListener.EventDispatcher createEventDispatcher(MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs)
MediaSourceEventListener.EventDispatcher which dispatches all events to the
registered listeners with the specified media period id and time offset.mediaPeriodId - The MediaPeriodId to be reported with the events.mediaTimeOffsetMs - The offset to be added to all media times, in milliseconds.protected final MediaSourceEventListener.EventDispatcher createEventDispatcher(int windowIndex, @Nullable MediaSource.MediaPeriodId mediaPeriodId, long mediaTimeOffsetMs)
MediaSourceEventListener.EventDispatcher which dispatches all events to the
registered listeners with the specified window index, media period id and time offset.windowIndex - The timeline window index to be reported with the events.mediaPeriodId - The MediaPeriodId to be reported with the events. May be null, if
the events do not belong to a specific media period.mediaTimeOffsetMs - The offset to be added to all media times, in milliseconds.public final void addEventListener(android.os.Handler handler,
MediaSourceEventListener eventListener)
MediaSourceMediaSourceEventListener to the list of listeners which are notified of media
source events.addEventListener in interface MediaSourcehandler - A handler on the which listener events will be posted.eventListener - The listener to be added.public final void removeEventListener(MediaSourceEventListener eventListener)
MediaSourceMediaSourceEventListener from the list of listeners which are notified of
media source events.removeEventListener in interface MediaSourceeventListener - The listener to be removed.public final void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.SourceInfoRefreshListener listener)
MediaSourceShould not be called directly from application code.
The listener will be also be notified if the source already has a timeline and/or manifest.
For each call to this method, a call to MediaSource.releaseSource(SourceInfoRefreshListener) is
needed to remove the listener and to release the source if no longer required.
prepareSource in interface MediaSourceplayer - The player for which this source is being prepared.isTopLevelSource - Whether this source has been passed directly to ExoPlayer.prepare(MediaSource) or ExoPlayer.prepare(MediaSource, boolean,
boolean). If false, this source is being prepared by another source (e.g. ConcatenatingMediaSource) for composition.listener - The listener to be added.public final void releaseSource(MediaSource.SourceInfoRefreshListener listener)
MediaSourceShould not be called directly from application code.
releaseSource in interface MediaSourcelistener - The listener to be removed.