public final class ClippingMediaSource extends 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, MediaSource.MediaPeriodId| Constructor and Description |
|---|
ClippingMediaSource(MediaSource mediaSource,
long startPositionUs,
long endPositionUs)
Creates a new clipping source that wraps the specified source.
|
ClippingMediaSource(MediaSource mediaSource,
long startPositionUs,
long endPositionUs,
boolean enableInitialDiscontinuity)
Creates a new clipping source that wraps the specified source.
|
| 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 |
onSourceInfoRefreshed(Timeline timeline,
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 ClippingMediaSource(MediaSource mediaSource, long startPositionUs, long endPositionUs, boolean enableInitialDiscontinuity)
If the start point is guaranteed to be a key frame, pass false to
enableInitialPositionDiscontinuity to suppress an initial discontinuity when a period
is first read from.
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.enableInitialDiscontinuity - Whether the initial discontinuity should be enabled.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 IOException
MediaSourcemaybeThrowSourceInfoRefreshError in interface MediaSourceIOExceptionpublic 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).createPeriod in interface MediaSourceid - The identifier of the period.allocator - An Allocator from which to obtain media buffer allocations.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, Object manifest)
MediaSource.ListeneronSourceInfoRefreshed in interface MediaSource.Listenertimeline - The source's timeline.manifest - The loaded manifest. May be null.