public final class LoopingMediaSource extends java.lang.Object implements MediaSource
MediaSource.MediaSource.Listener| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_EXPOSED_PERIODS
The maximum number of periods that can be exposed by the source.
|
| Constructor and Description |
|---|
LoopingMediaSource(MediaSource childSource)
Loops the provided source indefinitely.
|
LoopingMediaSource(MediaSource childSource,
int loopCount)
Loops the provided source a specified number of times.
|
| Modifier and Type | Method and Description |
|---|---|
MediaPeriod |
createPeriod(int index,
Allocator allocator,
long positionUs)
Returns a new
MediaPeriod corresponding to the period at the specified index. |
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 static final int MAX_EXPOSED_PERIODS
public LoopingMediaSource(MediaSource childSource)
childSource - The MediaSource to loop.public LoopingMediaSource(MediaSource childSource, int loopCount)
childSource - The MediaSource to loop.loopCount - The desired number of loops. Must be strictly positive. The actual number of
loops will be capped at the maximum that can achieved without causing the number of
periods exposed by the source to exceed MAX_EXPOSED_PERIODS.public void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.Listener listener)
MediaSourceprepareSource 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 for source events.public void maybeThrowSourceInfoRefreshError()
throws java.io.IOException
MediaSourcemaybeThrowSourceInfoRefreshError in interface MediaSourcejava.io.IOExceptionpublic MediaPeriod createPeriod(int index, Allocator allocator, long positionUs)
MediaSourceMediaPeriod corresponding to the period at the specified index.
This method may be called multiple times with the same index without an intervening call to
MediaSource.releasePeriod(MediaPeriod).createPeriod in interface MediaSourceindex - The index of the period.allocator - An Allocator from which to obtain media buffer allocations.positionUs - The player's current playback position.MediaPeriod.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSourcereleasePeriod in interface MediaSourcemediaPeriod - The period to release.public void releaseSource()
MediaSourceThis method should be called when the source is no longer required. It may be called in any state.
releaseSource in interface MediaSource