MediaSourcepublic final class LoopingMediaSource extends CompositeMediaSource<Void>
MediaSource a specified number of times.
Note: To loop a MediaSource indefinitely, it is usually better to use Player.setRepeatMode(int) instead of this class.
MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller| Constructor | 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 | Description |
|---|---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator,
long startPositionUs) |
Returns a new
MediaPeriod identified by periodId. |
Timeline |
getInitialTimeline() |
Returns the initial placeholder timeline that is returned immediately when the real timeline is
not yet known, or null to let the player create an initial timeline.
|
MediaItem |
getMediaItem() |
Returns the
MediaItem whose media is provided by the source. |
protected MediaSource.MediaPeriodId |
getMediaPeriodIdForChildMediaPeriodId(Void id,
MediaSource.MediaPeriodId mediaPeriodId) |
Returns the
MediaSource.MediaPeriodId in the composite source corresponding to the specified MediaSource.MediaPeriodId in a child source. |
Object |
getTag() |
Deprecated.
Use
getMediaItem() and MediaItem.PlaybackProperties.tag instead. |
boolean |
isSingleWindow() |
Returns true if the media source is guaranteed to never have zero or more than one window.
|
protected void |
onChildSourceInfoRefreshed(Void id,
MediaSource mediaSource,
Timeline timeline) |
Called when the source info of a child source has been refreshed.
|
protected void |
prepareSourceInternal(TransferListener mediaTransferListener) |
Starts source preparation and enables the source, see
BaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener). |
void |
releasePeriod(MediaPeriod mediaPeriod) |
Releases the period.
|
addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, enable, isEnabled, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListenerdisableChildSource, disableInternal, enableChildSource, enableInternal, getMediaTimeForChildMediaTime, getWindowIndexForChildWindowIndex, maybeThrowSourceInfoRefreshError, prepareChildSource, releaseChildSource, releaseSourceInternalpublic 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.@Deprecated @Nullable public Object getTag()
getMediaItem() and MediaItem.PlaybackProperties.tag instead.public MediaItem getMediaItem()
MediaSourceMediaItem whose media is provided by the source.@Nullable public Timeline getInitialTimeline()
MediaSourceThe initial timeline must use the same uids for windows and periods that the real timeline will use. It also must provide windows which are marked as dynamic to indicate that the window is expected to change when the real timeline arrives.
Any media source which has multiple windows should typically provide such an initial timeline to make sure the player reports the correct number of windows immediately.
public boolean isSingleWindow()
MediaSourceThe default implementation returns true.
protected void prepareSourceInternal(@Nullable
TransferListener mediaTransferListener)
BaseMediaSourceBaseMediaSource.prepareSource(MediaSourceCaller,
TransferListener). This method is called at most once until the next call to BaseMediaSource.releaseSourceInternal().prepareSourceInternal in class CompositeMediaSource<Void>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 MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs)
MediaSourceMediaPeriod identified by periodId.
Should not be called directly from application code.
Must only be called if the source is enabled.
id - The identifier of the period.allocator - An Allocator from which to obtain media buffer allocations.startPositionUs - The expected start position, in microseconds.MediaPeriod.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSourceShould not be called directly from application code.
mediaPeriod - The period to release.protected void onChildSourceInfoRefreshed(Void id, MediaSource mediaSource, Timeline timeline)
CompositeMediaSourceonChildSourceInfoRefreshed in class CompositeMediaSource<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.@Nullable protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(Void id, MediaSource.MediaPeriodId mediaPeriodId)
CompositeMediaSourceMediaSource.MediaPeriodId in the composite source corresponding to the specified MediaSource.MediaPeriodId in a child source. The default implementation does not change the media period
id.getMediaPeriodIdForChildMediaPeriodId in class CompositeMediaSource<Void>id - The unique id used to prepare the child source.mediaPeriodId - A MediaSource.MediaPeriodId of the child source.MediaSource.MediaPeriodId in the composite source. Null if no
corresponding media period id can be determined.