public final class MergingMediaSource extends CompositeMediaSource<java.lang.Integer>
MediaSource
s.
The Timeline
s of the sources being merged must have the same number of periods.
Modifier and Type | Class and Description |
---|---|
static class |
MergingMediaSource.IllegalMergeException
Thrown when a
MergingMediaSource cannot merge its sources. |
MediaSource.MediaPeriodId, MediaSource.SourceInfoRefreshListener
Constructor and Description |
---|
MergingMediaSource(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
MediaSource... mediaSources) |
MergingMediaSource(MediaSource... mediaSources) |
Modifier and Type | Method and Description |
---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator)
Returns a new
MediaPeriod identified by periodId . |
protected MediaSource.MediaPeriodId |
getMediaPeriodIdForChildMediaPeriodId(java.lang.Integer id,
MediaSource.MediaPeriodId mediaPeriodId)
Returns the
MediaPeriodId in the composite source corresponding to the specified MediaPeriodId in a child source. |
void |
maybeThrowSourceInfoRefreshError()
Throws any pending error encountered while loading or refreshing source information.
|
protected void |
onChildSourceInfoRefreshed(java.lang.Integer id,
MediaSource mediaSource,
Timeline timeline,
java.lang.Object manifest)
Called when the source info of a child source has been refreshed.
|
void |
prepareSourceInternal(ExoPlayer player,
boolean isTopLevelSource,
TransferListener mediaTransferListener)
Starts source preparation.
|
void |
releasePeriod(MediaPeriod mediaPeriod)
Releases the period.
|
void |
releaseSourceInternal()
Releases the source.
|
getMediaTimeForChildMediaTime, getWindowIndexForChildWindowIndex, prepareChildSource, releaseChildSource
addEventListener, createEventDispatcher, createEventDispatcher, createEventDispatcher, prepareSource, prepareSource, refreshSourceInfo, releaseSource, removeEventListener
public MergingMediaSource(MediaSource... mediaSources)
mediaSources
- The MediaSource
s to merge.public MergingMediaSource(CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory, MediaSource... mediaSources)
compositeSequenceableLoaderFactory
- A factory to create composite
SequenceableLoader
s for when this media source loads data from multiple streams
(video, audio etc...).mediaSources
- The MediaSource
s to merge.public void prepareSourceInternal(ExoPlayer player, boolean isTopLevelSource, @Nullable TransferListener mediaTransferListener)
BaseMediaSource
BaseMediaSource.releaseSourceInternal()
.prepareSourceInternal
in class CompositeMediaSource<java.lang.Integer>
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)
.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.public void maybeThrowSourceInfoRefreshError() throws java.io.IOException
MediaSource
Should not be called directly from application code.
maybeThrowSourceInfoRefreshError
in interface MediaSource
maybeThrowSourceInfoRefreshError
in class CompositeMediaSource<java.lang.Integer>
java.io.IOException
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator)
MediaSource
MediaPeriod
identified by periodId
. This method may be called
multiple times without an intervening call to MediaSource.releasePeriod(MediaPeriod)
.
Should not be called directly from application code.
id
- The identifier of the period.allocator
- An Allocator
from which to obtain media buffer allocations.MediaPeriod
.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSource
Should not be called directly from application code.
mediaPeriod
- The period to release.public void releaseSourceInternal()
BaseMediaSource
BaseMediaSource.prepareSourceInternal(ExoPlayer, boolean, TransferListener)
.releaseSourceInternal
in class CompositeMediaSource<java.lang.Integer>
protected void onChildSourceInfoRefreshed(java.lang.Integer id, MediaSource mediaSource, Timeline timeline, @Nullable java.lang.Object manifest)
CompositeMediaSource
onChildSourceInfoRefreshed
in class CompositeMediaSource<java.lang.Integer>
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.manifest
- The manifest of the child source.@Nullable protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(java.lang.Integer id, MediaSource.MediaPeriodId mediaPeriodId)
CompositeMediaSource
MediaPeriodId
in the composite source corresponding to the specified MediaPeriodId
in a child source. The default implementation does not change the media period
id.getMediaPeriodIdForChildMediaPeriodId
in class CompositeMediaSource<java.lang.Integer>
id
- The unique id used to prepare the child source.mediaPeriodId
- A MediaPeriodId
of the child source.MediaPeriodId
in the composite source. Null if no
corresponding media period id can be determined.