MediaSourcepublic final class MergingMediaSource extends CompositeMediaSource<Integer>
MediaSources.
The Timelines of the sources being merged must have the same number of periods.
| Modifier and Type | Class | Description |
|---|---|---|
static class |
MergingMediaSource.IllegalMergeException |
Thrown when a
MergingMediaSource cannot merge its sources. |
MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller| Constructor | Description |
|---|---|
MergingMediaSource(boolean adjustPeriodTimeOffsets,
boolean clipDurations,
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
MediaSource... mediaSources) |
Creates a merging media source.
|
MergingMediaSource(boolean adjustPeriodTimeOffsets,
boolean clipDurations,
MediaSource... mediaSources) |
Creates a merging media source.
|
MergingMediaSource(boolean adjustPeriodTimeOffsets,
MediaSource... mediaSources) |
Creates a merging media source.
|
MergingMediaSource(MediaSource... mediaSources) |
Creates a merging media source.
|
| Modifier and Type | Method | Description |
|---|---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator,
long startPositionUs) |
Returns a new
MediaPeriod identified by periodId. |
MediaItem |
getMediaItem() |
Returns the
MediaItem whose media is provided by the source. |
protected MediaSource.MediaPeriodId |
getMediaPeriodIdForChildMediaPeriodId(Integer 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. |
void |
maybeThrowSourceInfoRefreshError() |
Throws any pending error encountered while loading or refreshing source information.
|
protected void |
onChildSourceInfoRefreshed(Integer 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.
|
protected void |
releaseSourceInternal() |
Releases the source, see
BaseMediaSource.releaseSource(MediaSourceCaller). |
addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, enable, isEnabled, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListenerdisableChildSource, disableInternal, enableChildSource, enableInternal, getMediaTimeForChildMediaTime, getWindowIndexForChildWindowIndex, prepareChildSource, releaseChildSourcegetInitialTimeline, isSingleWindowpublic MergingMediaSource(MediaSource... mediaSources)
Neither offsets between the timestamps in the media sources nor the durations of the media sources will be adjusted.
mediaSources - The MediaSources to merge.public MergingMediaSource(boolean adjustPeriodTimeOffsets,
MediaSource... mediaSources)
Durations of the media sources will not be adjusted.
adjustPeriodTimeOffsets - Whether to adjust timestamps of the merged media sources to all
start at the same time.mediaSources - The MediaSources to merge.public MergingMediaSource(boolean adjustPeriodTimeOffsets,
boolean clipDurations,
MediaSource... mediaSources)
adjustPeriodTimeOffsets - Whether to adjust timestamps of the merged media sources to all
start at the same time.clipDurations - Whether to clip the durations of the media sources to match the shortest
duration.mediaSources - The MediaSources to merge.public MergingMediaSource(boolean adjustPeriodTimeOffsets,
boolean clipDurations,
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory,
MediaSource... mediaSources)
adjustPeriodTimeOffsets - Whether to adjust timestamps of the merged media sources to all
start at the same time.clipDurations - Whether to clip the durations of the media sources to match the shortest
duration.compositeSequenceableLoaderFactory - A factory to create composite SequenceableLoaders for when this media source loads data from multiple streams (video,
audio etc...).mediaSources - The MediaSources to merge.@Deprecated @Nullable public Object getTag()
getMediaItem() and MediaItem.PlaybackProperties.tag instead.public MediaItem getMediaItem()
MediaSourceMediaItem whose media is provided by the source.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<Integer>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 void maybeThrowSourceInfoRefreshError()
throws IOException
MediaSourceShould not be called directly from application code.
Must only be called after MediaSource.prepareSource(MediaSourceCaller, TransferListener).
maybeThrowSourceInfoRefreshError in interface MediaSourcemaybeThrowSourceInfoRefreshError in class CompositeMediaSource<Integer>IOExceptionpublic 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 releaseSourceInternal()
BaseMediaSourceBaseMediaSource.releaseSource(MediaSourceCaller). This method is called
exactly once after each call to BaseMediaSource.prepareSourceInternal(TransferListener).releaseSourceInternal in class CompositeMediaSource<Integer>protected void onChildSourceInfoRefreshed(Integer id, MediaSource mediaSource, Timeline timeline)
CompositeMediaSourceonChildSourceInfoRefreshed in class CompositeMediaSource<Integer>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(Integer 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<Integer>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.