public final class DynamicConcatenatingMediaSource extends CompositeMediaSource<com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource.MediaSourceHolder> implements PlayerMessage.Target
MediaSources. The list of MediaSources can be modified
during playback. Access to this class is thread-safe.MediaSource.Listener, MediaSource.MediaPeriodIdMEDIA_SOURCE_REUSED_ERROR_MESSAGE| Constructor and Description |
|---|
DynamicConcatenatingMediaSource()
Creates a new dynamic concatenating media source.
|
DynamicConcatenatingMediaSource(boolean isAtomic)
Creates a new dynamic concatenating media source.
|
DynamicConcatenatingMediaSource(boolean isAtomic,
ShuffleOrder shuffleOrder)
Creates a new dynamic concatenating media source with a custom shuffle order.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMediaSource(int index,
MediaSource mediaSource)
Adds a
MediaSource to the playlist. |
void |
addMediaSource(int index,
MediaSource mediaSource,
java.lang.Runnable actionOnCompletion)
Adds a
MediaSource to the playlist and executes a custom action on completion. |
void |
addMediaSource(MediaSource mediaSource)
Appends a
MediaSource to the playlist. |
void |
addMediaSource(MediaSource mediaSource,
java.lang.Runnable actionOnCompletion)
Appends a
MediaSource to the playlist and executes a custom action on completion. |
void |
addMediaSources(java.util.Collection<MediaSource> mediaSources)
Appends multiple
MediaSources to the playlist. |
void |
addMediaSources(java.util.Collection<MediaSource> mediaSources,
java.lang.Runnable actionOnCompletion)
Appends multiple
MediaSources to the playlist and executes a custom action on
completion. |
void |
addMediaSources(int index,
java.util.Collection<MediaSource> mediaSources)
Adds multiple
MediaSources to the playlist. |
void |
addMediaSources(int index,
java.util.Collection<MediaSource> mediaSources,
java.lang.Runnable actionOnCompletion)
Adds multiple
MediaSources to the playlist and executes a custom action on completion. |
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 target.
|
void |
moveMediaSource(int currentIndex,
int newIndex)
Moves an existing
MediaSource within the playlist. |
void |
moveMediaSource(int currentIndex,
int newIndex,
java.lang.Runnable actionOnCompletion)
Moves an existing
MediaSource within the playlist and executes a custom action on
completion. |
protected void |
onChildSourceInfoRefreshed(com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource.MediaSourceHolder mediaSourceHolder,
MediaSource mediaSource,
Timeline timeline,
java.lang.Object manifest)
Called when the source info of a child source 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.
|
void |
removeMediaSource(int index)
Removes a
MediaSource from the playlist. |
void |
removeMediaSource(int index,
java.lang.Runnable actionOnCompletion)
Removes a
MediaSource from the playlist and executes a custom action on completion. |
maybeThrowSourceInfoRefreshError, prepareChildSource, releaseChildSourcepublic DynamicConcatenatingMediaSource()
public DynamicConcatenatingMediaSource(boolean isAtomic)
isAtomic - Whether the concatenating media source will be treated as atomic, i.e., treated
as a single item for repeating and shuffling.public DynamicConcatenatingMediaSource(boolean isAtomic,
ShuffleOrder shuffleOrder)
isAtomic - Whether the concatenating media source will be treated as atomic, i.e., treated
as a single item for repeating and shuffling.shuffleOrder - The ShuffleOrder to use when shuffling the child media sources.
This shuffle order must be empty.public void addMediaSource(MediaSource mediaSource)
MediaSource to the playlist.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
mediaSource - The MediaSource to be added to the list.public void addMediaSource(MediaSource mediaSource, @Nullable java.lang.Runnable actionOnCompletion)
MediaSource to the playlist and executes a custom action on completion.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
mediaSource - The MediaSource to be added to the list.actionOnCompletion - A Runnable which is executed immediately after the media
source has been added to the playlist.public void addMediaSource(int index,
MediaSource mediaSource)
MediaSource to the playlist.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
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 addMediaSource(int index,
MediaSource mediaSource,
@Nullable
java.lang.Runnable actionOnCompletion)
MediaSource to the playlist and executes a custom action on completion.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
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.actionOnCompletion - A Runnable which is executed immediately after the media
source has been added to the playlist.public void addMediaSources(java.util.Collection<MediaSource> mediaSources)
MediaSources to the playlist.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
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(java.util.Collection<MediaSource> mediaSources, @Nullable java.lang.Runnable actionOnCompletion)
MediaSources to the playlist and executes a custom action on
completion.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
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.actionOnCompletion - A Runnable which is executed immediately after the media
sources have been added to the playlist.public void addMediaSources(int index,
java.util.Collection<MediaSource> mediaSources)
MediaSources to the playlist.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
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 addMediaSources(int index,
java.util.Collection<MediaSource> mediaSources,
@Nullable
java.lang.Runnable actionOnCompletion)
MediaSources to the playlist and executes a custom action on completion.
Note: MediaSource instances are not designed to be re-used. If you want to add the same
piece of media multiple times, use a new instance each time.
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.actionOnCompletion - A Runnable which is executed immediately after the media
sources have been added to the playlist.public void removeMediaSource(int index)
MediaSource from the playlist.
Note: MediaSource instances are not designed to be re-used, and so the instance being
removed should not be re-added. If you want to move the instance use
moveMediaSource(int, int) instead.
index - The index at which the media source will be removed. This index must be in the
range of 0 <= index < getSize().public void removeMediaSource(int index,
@Nullable
java.lang.Runnable actionOnCompletion)
MediaSource from the playlist and executes a custom action on completion.
Note: MediaSource instances are not designed to be re-used, and so the instance being
removed should not be re-added. If you want to move the instance use
moveMediaSource(int, int) instead.
index - The index at which the media source will be removed. This index must be in the
range of 0 <= index < getSize().actionOnCompletion - A Runnable which is executed immediately after the media
source has been removed from the playlist.public void moveMediaSource(int currentIndex,
int newIndex)
MediaSource within the playlist.public void moveMediaSource(int currentIndex,
int newIndex,
@Nullable
java.lang.Runnable actionOnCompletion)
MediaSource within the playlist and executes a custom action on
completion.currentIndex - The current index of the media source in the playlist. This index must be
in the range of 0 <= index < getSize().newIndex - The target index of the media source in the playlist. This index must be in the
range of 0 <= index < getSize().actionOnCompletion - A Runnable which is executed immediately after the media
source has been moved.public int getSize()
public MediaSource getMediaSource(int index)
MediaSource at a specified index.index - An index in the range of 0 <= index <= getSize().MediaSource at this index.public void prepareSource(ExoPlayer player, boolean isTopLevelSource, MediaSource.Listener listener)
MediaSourceShould not be called directly from application code.
prepareSource in interface MediaSourceprepareSource in class CompositeMediaSource<com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource.MediaSourceHolder>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 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).
Should not be called directly from application code.
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)
MediaSourceShould not be called directly from application code.
releasePeriod in interface MediaSourcemediaPeriod - The period to release.public void releaseSource()
MediaSourceShould not be called directly from application code.
releaseSource in interface MediaSourcereleaseSource in class CompositeMediaSource<com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource.MediaSourceHolder>protected void onChildSourceInfoRefreshed(com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource.MediaSourceHolder mediaSourceHolder,
MediaSource mediaSource,
Timeline timeline,
@Nullable
java.lang.Object manifest)
CompositeMediaSourceonChildSourceInfoRefreshed in class CompositeMediaSource<com.google.android.exoplayer2.source.DynamicConcatenatingMediaSource.MediaSourceHolder>mediaSourceHolder - 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.manifest - The manifest of the child source.public void handleMessage(int messageType,
java.lang.Object message)
throws ExoPlaybackException
PlayerMessage.TargethandleMessage in interface PlayerMessage.TargetmessageType - The message type.message - The message payload.ExoPlaybackException - If an error occurred whilst handling the message. Should only be
thrown by targets that handle messages on the playback thread.