public final class DynamicConcatenatingMediaSource extends java.lang.Object implements MediaSource, ExoPlayer.ExoPlayerComponent
MediaSource
s. The list of MediaSource
s 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(java.util.Collection<MediaSource> mediaSources)
Appends multiple
MediaSource s to the playlist. |
void |
addMediaSources(int index,
java.util.Collection<MediaSource> mediaSources)
Adds multiple
MediaSource s 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,
java.lang.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(java.util.Collection<MediaSource> mediaSources)
MediaSource
s to the playlist.mediaSources
- A collection of MediaSource
s 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, java.util.Collection<MediaSource> mediaSources)
MediaSource
s to the playlist.index
- The index at which the new MediaSource
s will be inserted. This index must
be in the range of 0 <= index <= getSize()
.mediaSources
- A collection of MediaSource
s 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)
MediaSource
prepareSource
in interface MediaSource
player
- 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
MediaSource
maybeThrowSourceInfoRefreshError
in interface MediaSource
java.io.IOException
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator)
MediaSource
MediaPeriod
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 MediaSource
id
- The identifier of the period.allocator
- An Allocator
from which to obtain media buffer allocations.MediaPeriod
.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSource
releasePeriod
in interface MediaSource
mediaPeriod
- The period to release.public void releaseSource()
MediaSource
This method should be called when the source is no longer required. It may be called in any state.
releaseSource
in interface MediaSource
public void handleMessage(int messageType, java.lang.Object message) throws ExoPlaybackException
ExoPlayer.ExoPlayerComponent
handleMessage
in interface ExoPlayer.ExoPlayerComponent
messageType
- The message type.message
- The message.ExoPlaybackException
- If an error occurred whilst handling the message.