public final class LoopingMediaSource extends CompositeMediaSource<java.lang.Void>
MediaSource a specified number of times.
Note: To loop a MediaSource indefinitely, it is usually better to use Player.setRepeatMode(int).
MediaSource.Listener, MediaSource.MediaPeriodIdMEDIA_SOURCE_REUSED_ERROR_MESSAGE| 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(MediaSource.MediaPeriodId id,
Allocator allocator)
Returns a new
MediaPeriod identified by periodId. |
protected void |
onChildSourceInfoRefreshed(java.lang.Void id,
MediaSource mediaSource,
Timeline timeline,
java.lang.Object manifest)
Called when the source info of a child source has been refreshed.
|
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.
|
maybeThrowSourceInfoRefreshError, prepareChildSource, releaseChildSourcepublic LoopingMediaSource(MediaSource childSource)
Player.setRepeatMode(int).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.public void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.Listener listener)
MediaSourceShould not be called directly from application code.
prepareSource in interface MediaSourceprepareSource in class CompositeMediaSource<java.lang.Void>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 MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator)
MediaSourceMediaPeriod identified by periodId. This method may be called
multiple times with the same period identifier 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)
MediaSourceShould not be called directly from application code.
mediaPeriod - The period to release.public void releaseSource()
MediaSourceShould not be called directly from application code.
releaseSource in interface MediaSourcereleaseSource in class CompositeMediaSource<java.lang.Void>protected void onChildSourceInfoRefreshed(java.lang.Void id,
MediaSource mediaSource,
Timeline timeline,
@Nullable
java.lang.Object manifest)
CompositeMediaSourceonChildSourceInfoRefreshed in class CompositeMediaSource<java.lang.Void>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.