public final class ClippingMediaSource extends java.lang.Object implements MediaSource, MediaSource.Listener
MediaSource that wraps a source and clips its timeline based on specified start/end
positions. The wrapped source may only have a single period/window and it must not be dynamic
(live).MediaSource.Listener| Constructor and Description |
|---|
ClippingMediaSource(MediaSource mediaSource,
long startPositionUs,
long endPositionUs)
Creates a new clipping source that wraps the specified source.
|
| 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 |
onSourceInfoRefreshed(Timeline timeline,
java.lang.Object manifest)
Called when manifest and/or timeline 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.
|
public ClippingMediaSource(MediaSource mediaSource, long startPositionUs, long endPositionUs)
mediaSource - The single-period, non-dynamic source to wrap.startPositionUs - The start position within mediaSource's timeline at which to
start providing samples, in microseconds.endPositionUs - The end position within mediaSource's timeline at which to stop
providing samples, in microseconds. Specify C.TIME_END_OF_SOURCE to provide samples
from the specified start point up to the end of the source.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 MediaSourcepublic void onSourceInfoRefreshed(Timeline timeline, java.lang.Object manifest)
MediaSource.ListeneronSourceInfoRefreshed in interface MediaSource.Listenertimeline - The source's timeline.manifest - The loaded manifest.