Class CompositeMediaSource<T>
- java.lang.Object
-
- com.google.android.exoplayer2.source.BaseMediaSource
-
- com.google.android.exoplayer2.source.CompositeMediaSource<T>
-
- Type Parameters:
T- The type of the id used to identify prepared child sources.
- All Implemented Interfaces:
MediaSource
- Direct Known Subclasses:
AdsMediaSource,ClippingMediaSource,ConcatenatingMediaSource,LoopingMediaSource,MaskingMediaSource,MergingMediaSource
public abstract class CompositeMediaSource<T> extends BaseMediaSource
CompositeMediaSourceconsisting of multiple child sources.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.MediaSource
MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCompositeMediaSource()Creates composite media source without child sources.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddisableChildSource(T id)Disables a child source.protected voiddisableInternal()Disables the source, seeBaseMediaSource.disable(MediaSourceCaller).protected voidenableChildSource(T id)Enables a child source.protected voidenableInternal()Enables the source, seeBaseMediaSource.enable(MediaSourceCaller).protected MediaSource.MediaPeriodIdgetMediaPeriodIdForChildMediaPeriodId(T id, MediaSource.MediaPeriodId mediaPeriodId)Returns theMediaSource.MediaPeriodIdin the composite source corresponding to the specifiedMediaSource.MediaPeriodIdin a child source.protected longgetMediaTimeForChildMediaTime(T id, long mediaTimeMs)Returns the media time in theMediaPeriodof the composite source corresponding to the specified media time in theMediaPeriodof the child source.protected intgetWindowIndexForChildWindowIndex(T id, int windowIndex)Returns the window index in the composite source corresponding to the specified window index in a child source.voidmaybeThrowSourceInfoRefreshError()Throws any pending error encountered while loading or refreshing source information.protected abstract voidonChildSourceInfoRefreshed(T id, MediaSource mediaSource, Timeline timeline)Called when the source info of a child source has been refreshed.protected voidprepareChildSource(T id, MediaSource mediaSource)Prepares a child source.protected voidprepareSourceInternal(TransferListener mediaTransferListener)Starts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener).protected voidreleaseChildSource(T id)Releases a child source.protected voidreleaseSourceInternal()Releases the source, seeBaseMediaSource.releaseSource(MediaSourceCaller).-
Methods inherited from class com.google.android.exoplayer2.source.BaseMediaSource
addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, enable, isEnabled, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListener
-
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, releasePeriod
-
-
-
-
Method Detail
-
prepareSourceInternal
@CallSuper protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)Description copied from class:BaseMediaSourceStarts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener). This method is called at most once until the next call toBaseMediaSource.releaseSourceInternal().- Specified by:
prepareSourceInternalin classBaseMediaSource- 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.
-
maybeThrowSourceInfoRefreshError
@CallSuper public void maybeThrowSourceInfoRefreshError() throws IOExceptionDescription copied from interface:MediaSourceThrows any pending error encountered while loading or refreshing source information.Should not be called directly from application code.
Must only be called after
MediaSource.prepareSource(MediaSourceCaller, TransferListener).- Throws:
IOException
-
enableInternal
@CallSuper protected void enableInternal()
Description copied from class:BaseMediaSourceEnables the source, seeBaseMediaSource.enable(MediaSourceCaller).- Overrides:
enableInternalin classBaseMediaSource
-
disableInternal
@CallSuper protected void disableInternal()
Description copied from class:BaseMediaSourceDisables the source, seeBaseMediaSource.disable(MediaSourceCaller).- Overrides:
disableInternalin classBaseMediaSource
-
releaseSourceInternal
@CallSuper protected void releaseSourceInternal()
Description copied from class:BaseMediaSourceReleases the source, seeBaseMediaSource.releaseSource(MediaSourceCaller). This method is called exactly once after each call toBaseMediaSource.prepareSourceInternal(TransferListener).- Specified by:
releaseSourceInternalin classBaseMediaSource
-
onChildSourceInfoRefreshed
protected abstract void onChildSourceInfoRefreshed(T id, MediaSource mediaSource, Timeline timeline)
Called when the source info of a child source has been refreshed.- Parameters:
id- The unique id used to prepare the child source.mediaSource- The child source whose source info has been refreshed.timeline- The timeline of the child source.
-
prepareChildSource
protected final void prepareChildSource(T id, MediaSource mediaSource)
Prepares a child source.onChildSourceInfoRefreshed(Object, MediaSource, Timeline)will be called when the child source updates its timeline with the sameidpassed to this method.Any child sources that aren't explicitly released with
releaseChildSource(Object)will be released inreleaseSourceInternal().- Parameters:
id- A unique id to identify the child source preparation. Null is allowed as an id.mediaSource- The childMediaSource.
-
enableChildSource
protected final void enableChildSource(T id)
Enables a child source.- Parameters:
id- The unique id used to prepare the child source.
-
disableChildSource
protected final void disableChildSource(T id)
Disables a child source.- Parameters:
id- The unique id used to prepare the child source.
-
releaseChildSource
protected final void releaseChildSource(T id)
Releases a child source.- Parameters:
id- The unique id used to prepare the child source.
-
getWindowIndexForChildWindowIndex
protected int getWindowIndexForChildWindowIndex(T id, int windowIndex)
Returns the window index in the composite source corresponding to the specified window index in a child source. The default implementation does not change the window index.- Parameters:
id- The unique id used to prepare the child source.windowIndex- A window index of the child source.- Returns:
- The corresponding window index in the composite source.
-
getMediaPeriodIdForChildMediaPeriodId
@Nullable protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(T id, MediaSource.MediaPeriodId mediaPeriodId)
Returns theMediaSource.MediaPeriodIdin the composite source corresponding to the specifiedMediaSource.MediaPeriodIdin a child source. The default implementation does not change the media period id.- Parameters:
id- The unique id used to prepare the child source.mediaPeriodId- AMediaSource.MediaPeriodIdof the child source.- Returns:
- The corresponding
MediaSource.MediaPeriodIdin the composite source. Null if no corresponding media period id can be determined.
-
getMediaTimeForChildMediaTime
protected long getMediaTimeForChildMediaTime(T id, long mediaTimeMs)
Returns the media time in theMediaPeriodof the composite source corresponding to the specified media time in theMediaPeriodof the child source. The default implementation does not change the media time.- Parameters:
id- The unique id used to prepare the child source.mediaTimeMs- A media time in theMediaPeriodof the child source, in milliseconds.- Returns:
- The corresponding media time in the
MediaPeriodof the composite source, in milliseconds.
-
-