public final class DynamicConcatenatingMediaSource extends Object implements MediaSource, ExoPlayer.ExoPlayerComponent
MediaSources. The list of MediaSources can be modified
during playback. Access to this class is thread-safe.MediaSource.Listener, MediaSource.MediaPeriodId| Constructor and Description |
|---|
DynamicConcatenatingMediaSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
addMediaSource(int index,
MediaSource mediaSource)
Adds a
MediaSource to the playlist. |
void |
addMediaSource(MediaSource mediaSource)
Appends a
MediaSource to the playlist. |
void |
addMediaSources(Collection<MediaSource> mediaSources)
Appends multiple
MediaSources to the playlist. |
void |
addMediaSources(int index,
Collection<MediaSource> mediaSources)
Adds multiple
MediaSources to the playlist. |
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator)
Returns a new
MediaPeriod identified by periodId. |
MediaSource |
getMediaSource(int index)
Returns the
MediaSource at a specified index. |
int |
getSize()
Returns the number of media sources in the playlist.
|
void |
handleMessage(int messageType,
Object message)
Handles a message delivered to the component.
|
void |
maybeThrowSourceInfoRefreshError()
Throws any pending error encountered while loading or refreshing source information.
|
void |
moveMediaSource(int currentIndex,
int newIndex)
Moves an existing
MediaSource within the playlist. |
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.
|
void |
removeMediaSource(int index)
Removes a
MediaSource from the playlist. |
public void addMediaSource(MediaSource mediaSource)
MediaSource to the playlist.mediaSource - The MediaSource to be added to the list.public void addMediaSource(int index,
MediaSource mediaSource)
MediaSource to the playlist.index - The index at which the new MediaSource will be inserted. This index must
be in the range of 0 <= index <= getSize().mediaSource - The MediaSource to be added to the list.public void addMediaSources(Collection<MediaSource> mediaSources)
MediaSources to the playlist.mediaSources - A collection of MediaSources to be added to the list. The media
sources are added in the order in which they appear in this collection.public void addMediaSources(int index,
Collection<MediaSource> mediaSources)
MediaSources to the playlist.index - The index at which the new MediaSources will be inserted. This index must
be in the range of 0 <= index <= getSize().mediaSources - A collection of MediaSources to be added to the list. The media
sources are added in the order in which they appear in this collection.public void removeMediaSource(int index)
MediaSource from the playlist.index - The index at which the media source will be removed. This index must be in the
range of 0 <= index < getSize().public void moveMediaSource(int currentIndex,
int newIndex)
MediaSource within the playlist.public int getSize()
public MediaSource getMediaSource(int index)
MediaSource at a specified index.index - A index in the range of 0 <= index <= getSize().MediaSource at this index.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 handleMessage(int messageType,
Object message)
throws ExoPlaybackException
ExoPlayer.ExoPlayerComponenthandleMessage in interface ExoPlayer.ExoPlayerComponentmessageType - The message type.message - The message.ExoPlaybackException - If an error occurred whilst handling the message.