public final class MergingMediaSource extends Object implements MediaSource
MediaSource
s.
The Timeline
s of the sources being merged must have the same number of periods, and must
not have any dynamic windows.
Modifier and Type | Class and Description |
---|---|
static class |
MergingMediaSource.IllegalMergeException
Thrown when a
MergingMediaSource cannot merge its sources. |
MediaSource.Listener, MediaSource.MediaPeriodId
Constructor and Description |
---|
MergingMediaSource(MediaSource... mediaSources) |
Modifier and Type | Method and Description |
---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator)
Returns a new
MediaPeriod identified by periodId . |
void |
maybeThrowSourceInfoRefreshError()
Throws any pending error encountered while loading or refreshing source information.
|
void |
prepareSource(ExoPlayer player,
boolean isTopLevelSource,
MediaSource.Listener listener)
Starts preparation of the source.
|
void |
releasePeriod(MediaPeriod mediaPeriod)
Releases the period.
|
void |
releaseSource()
Releases the source.
|
public MergingMediaSource(MediaSource... mediaSources)
mediaSources
- The MediaSource
s to merge.public void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.Listener listener)
MediaSource
prepareSource
in interface MediaSource
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)
. If false
, this source is
being prepared by another source (e.g. ConcatenatingMediaSource
) for composition.listener
- The listener for source events.public void maybeThrowSourceInfoRefreshError() throws IOException
MediaSource
maybeThrowSourceInfoRefreshError
in interface MediaSource
IOException
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator)
MediaSource
MediaPeriod
identified by periodId
. This method may be called
multiple times with the same period identifier without an intervening call to
MediaSource.releasePeriod(MediaPeriod)
.createPeriod
in interface MediaSource
id
- The identifier of the period.allocator
- An Allocator
from which to obtain media buffer allocations.MediaPeriod
.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSource
releasePeriod
in interface MediaSource
mediaPeriod
- The period to release.public void releaseSource()
MediaSource
This method should be called when the source is no longer required. It may be called in any state.
releaseSource
in interface MediaSource