ConcatenatingMediaSource


@UnstableApi
class ConcatenatingMediaSource : CompositeMediaSource<ConcatenatingMediaSource.MediaSourceHolder!>


Concatenates multiple MediaSource instances. The list of MediaSource instances can be modified during playback. It is valid for the same MediaSource instance to be present more than once in the concatenation. Access to this class is thread-safe.

Summary

Nested types

This class is deprecated. Deprecated in Java

Public constructors

This function is deprecated. Deprecated in Java

ConcatenatingMediaSource(
    isAtomic: Boolean,
    mediaSources: Array<MediaSource!>!
)

This function is deprecated. Deprecated in Java

ConcatenatingMediaSource(
    isAtomic: Boolean,
    shuffleOrder: ShuffleOrder!,
    mediaSources: Array<MediaSource!>!
)

This function is deprecated. Deprecated in Java

ConcatenatingMediaSource(
    isAtomic: Boolean,
    useLazyPreparation: Boolean,
    shuffleOrder: ShuffleOrder!,
    mediaSources: Array<MediaSource!>!
)

This function is deprecated. Deprecated in Java

Public functions

synchronized Unit
addMediaSource(mediaSource: MediaSource!)

This function is deprecated. Deprecated in Java

synchronized Unit
addMediaSource(index: Int, mediaSource: MediaSource!)

This function is deprecated. Deprecated in Java

synchronized Unit
addMediaSource(
    mediaSource: MediaSource!,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

synchronized Unit
addMediaSource(
    index: Int,
    mediaSource: MediaSource!,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

synchronized Unit

This function is deprecated. Deprecated in Java

synchronized Unit
addMediaSources(
    index: Int,
    mediaSources: (Mutable)Collection<MediaSource!>!
)

This function is deprecated. Deprecated in Java

synchronized Unit
addMediaSources(
    mediaSources: (Mutable)Collection<MediaSource!>!,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

synchronized Unit
addMediaSources(
    index: Int,
    mediaSources: (Mutable)Collection<MediaSource!>!,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

synchronized Unit

This function is deprecated. Deprecated in Java

synchronized Unit
clear(handler: Handler!, onCompletionAction: Runnable!)

This function is deprecated. Deprecated in Java

MediaPeriod!
createPeriod(
    id: MediaSource.MediaPeriodId!,
    allocator: Allocator!,
    startPositionUs: Long
)

This function is deprecated. Deprecated in Java

synchronized Timeline!

This function is deprecated. Deprecated in Java

MediaItem!

This function is deprecated. Deprecated in Java

synchronized MediaSource!

This function is deprecated. Deprecated in Java

synchronized Int

This function is deprecated. Deprecated in Java

Boolean

This function is deprecated. Deprecated in Java

synchronized Unit
moveMediaSource(currentIndex: Int, newIndex: Int)

This function is deprecated. Deprecated in Java

synchronized Unit
moveMediaSource(
    currentIndex: Int,
    newIndex: Int,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

Unit
releasePeriod(mediaPeriod: MediaPeriod!)

This function is deprecated. Deprecated in Java

synchronized MediaSource!

This function is deprecated. Deprecated in Java

synchronized MediaSource!
removeMediaSource(
    index: Int,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

synchronized Unit
removeMediaSourceRange(fromIndex: Int, toIndex: Int)

This function is deprecated. Deprecated in Java

synchronized Unit
removeMediaSourceRange(
    fromIndex: Int,
    toIndex: Int,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

synchronized Unit
setShuffleOrder(shuffleOrder: ShuffleOrder!)

This function is deprecated. Deprecated in Java

synchronized Unit
setShuffleOrder(
    shuffleOrder: ShuffleOrder!,
    handler: Handler!,
    onCompletionAction: Runnable!
)

This function is deprecated. Deprecated in Java

Protected functions

Unit

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

MediaSource.MediaPeriodId?

This function is deprecated. Deprecated in Java

Int

This function is deprecated. Deprecated in Java

Unit
onChildSourceInfoRefreshed(
    childSourceId: ConcatenatingMediaSource.MediaSourceHolder!,
    mediaSource: MediaSource!,
    newTimeline: Timeline!
)

This function is deprecated. Deprecated in Java

synchronized Unit
prepareSourceInternal(mediaTransferListener: TransferListener?)

This function is deprecated. Deprecated in Java

synchronized Unit

This function is deprecated. Deprecated in Java

Inherited functions

From androidx.media3.exoplayer.source.BaseMediaSource
Unit
@UnstableApi
addDrmEventListener(
    handler: Handler!,
    eventListener: DrmSessionEventListener!
)

This function is deprecated. Deprecated in Java

Unit
@UnstableApi
addEventListener(
    handler: Handler!,
    eventListener: MediaSourceEventListener!
)

This function is deprecated. Deprecated in Java

DrmSessionEventListener.EventDispatcher!

This function is deprecated. Deprecated in Java

DrmSessionEventListener.EventDispatcher!
createDrmEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

This function is deprecated. Deprecated in Java

MediaSourceEventListener.EventDispatcher!

This function is deprecated. Deprecated in Java

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    mediaPeriodId: MediaSource.MediaPeriodId!,
    mediaTimeOffsetMs: Long
)

This function is deprecated.

Use createEventDispatcher instead.

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

This function is deprecated. Deprecated in Java

MediaSourceEventListener.EventDispatcher!
createEventDispatcher(
    windowIndex: Int,
    mediaPeriodId: MediaSource.MediaPeriodId?,
    mediaTimeOffsetMs: Long
)

This function is deprecated.

Use createEventDispatcher instead.

Unit

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

Boolean

This function is deprecated. Deprecated in Java

Unit
@UnstableApi
prepareSource(
    caller: MediaSource.MediaSourceCaller!,
    playerId: PlayerId!,
    bandwidthMeter: BandwidthMeter!
)

This function is deprecated. Deprecated in Java

Boolean

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

From androidx.media3.exoplayer.source.CompositeMediaSource
Unit

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

Long
getMediaTimeForChildMediaTime(
    @UnknownNull childSourceId: T!,
    mediaTimeMs: Long,
    mediaPeriodId: MediaSource.MediaPeriodId?
)

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

Unit
prepareChildSource(@UnknownNull id: T!, mediaSource: MediaSource!)

This function is deprecated. Deprecated in Java

Unit

This function is deprecated. Deprecated in Java

From androidx.media3.exoplayer.source.MediaSource
Boolean

This function is deprecated. Deprecated in Java

Unit
@UnstableApi
prepareSource(
    caller: MediaSource.MediaSourceCaller!,
    mediaTransferListener: TransferListener?,
    playerId: PlayerId!
)

This function is deprecated.

Use prepareSource instead.

Unit

This function is deprecated. Deprecated in Java

Inherited properties

From androidx.media3.exoplayer.source.BaseMediaSource
BandwidthMeter?

This property is deprecated. Deprecated in Java

PlayerId?

This property is deprecated. Deprecated in Java

Public constructors

ConcatenatingMediaSource

ConcatenatingMediaSource(mediaSources: Array<MediaSource!>!)
Parameters
mediaSources: Array<MediaSource!>!

The MediaSources to concatenate. It is valid for the same MediaSource instance to be present more than once in the array.

ConcatenatingMediaSource

ConcatenatingMediaSource(
    isAtomic: Boolean,
    mediaSources: Array<MediaSource!>!
)
Parameters
isAtomic: Boolean

Whether the concatenating media source will be treated as atomic, i.e., treated as a single item for repeating and shuffling.

mediaSources: Array<MediaSource!>!

The MediaSources to concatenate. It is valid for the same MediaSource instance to be present more than once in the array.

ConcatenatingMediaSource

ConcatenatingMediaSource(
    isAtomic: Boolean,
    shuffleOrder: ShuffleOrder!,
    mediaSources: Array<MediaSource!>!
)
Parameters
isAtomic: Boolean

Whether the concatenating media source will be treated as atomic, i.e., treated as a single item for repeating and shuffling.

shuffleOrder: ShuffleOrder!

The ShuffleOrder to use when shuffling the child media sources.

mediaSources: Array<MediaSource!>!

The MediaSources to concatenate. It is valid for the same MediaSource instance to be present more than once in the array.

ConcatenatingMediaSource

ConcatenatingMediaSource(
    isAtomic: Boolean,
    useLazyPreparation: Boolean,
    shuffleOrder: ShuffleOrder!,
    mediaSources: Array<MediaSource!>!
)
Parameters
isAtomic: Boolean

Whether the concatenating media source will be treated as atomic, i.e., treated as a single item for repeating and shuffling.

useLazyPreparation: Boolean

Whether playlist items are prepared lazily. If false, all manifest loads and other initial preparation steps happen immediately. If true, these initial preparations are triggered only when the player starts buffering the media.

shuffleOrder: ShuffleOrder!

The ShuffleOrder to use when shuffling the child media sources.

mediaSources: Array<MediaSource!>!

The MediaSources to concatenate. It is valid for the same MediaSource instance to be present more than once in the array.

Public functions

addMediaSource

synchronized fun addMediaSource(mediaSource: MediaSource!): Unit

Appends a MediaSource to the playlist.

Parameters
mediaSource: MediaSource!

The MediaSource to be added to the list.

addMediaSource

synchronized fun addMediaSource(index: Int, mediaSource: MediaSource!): Unit

Adds a MediaSource to the playlist.

Parameters
index: Int

The index at which the new MediaSource will be inserted. This index must be in the range of 0 <= index <= getSize.

mediaSource: MediaSource!

The MediaSource to be added to the list.

addMediaSource

synchronized fun addMediaSource(
    mediaSource: MediaSource!,
    handler: Handler!,
    onCompletionAction: Runnable!
): Unit

Appends a MediaSource to the playlist and executes a custom action on completion.

Parameters
mediaSource: MediaSource!

The MediaSource to be added to the list.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the media source has been added to the playlist.

addMediaSource

synchronized fun addMediaSource(
    index: Int,
    mediaSource: MediaSource!,
    handler: Handler!,
    onCompletionAction: Runnable!
): Unit

Adds a MediaSource to the playlist and executes a custom action on completion.

Parameters
index: Int

The index at which the new MediaSource will be inserted. This index must be in the range of 0 <= index <= getSize.

mediaSource: MediaSource!

The MediaSource to be added to the list.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the media source has been added to the playlist.

addMediaSources

synchronized fun addMediaSources(mediaSources: (Mutable)Collection<MediaSource!>!): Unit

Appends multiple MediaSources to the playlist.

Parameters
mediaSources: (Mutable)Collection<MediaSource!>!

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.

addMediaSources

synchronized fun addMediaSources(
    index: Int,
    mediaSources: (Mutable)Collection<MediaSource!>!
): Unit

Adds multiple MediaSources to the playlist.

Parameters
index: Int

The index at which the new MediaSources will be inserted. This index must be in the range of 0 <= index <= getSize.

mediaSources: (Mutable)Collection<MediaSource!>!

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.

addMediaSources

synchronized fun addMediaSources(
    mediaSources: (Mutable)Collection<MediaSource!>!,
    handler: Handler!,
    onCompletionAction: Runnable!
): Unit

Appends multiple MediaSources to the playlist and executes a custom action on completion.

Parameters
mediaSources: (Mutable)Collection<MediaSource!>!

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.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the media sources have been added to the playlist.

addMediaSources

synchronized fun addMediaSources(
    index: Int,
    mediaSources: (Mutable)Collection<MediaSource!>!,
    handler: Handler!,
    onCompletionAction: Runnable!
): Unit

Adds multiple MediaSources to the playlist and executes a custom action on completion.

Parameters
index: Int

The index at which the new MediaSources will be inserted. This index must be in the range of 0 <= index <= getSize.

mediaSources: (Mutable)Collection<MediaSource!>!

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.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the media sources have been added to the playlist.

clear

synchronized fun clear(): Unit

Clears the playlist.

clear

synchronized fun clear(handler: Handler!, onCompletionAction: Runnable!): Unit

Clears the playlist and executes a custom action on completion.

Parameters
handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the playlist has been cleared.

createPeriod

fun createPeriod(
    id: MediaSource.MediaPeriodId!,
    allocator: Allocator!,
    startPositionUs: Long
): MediaPeriod!

Returns a new MediaPeriod identified by periodId.

Should not be called directly from application code.

This method must be called on the playback thread and only if the source is enabled.

Parameters
id: MediaSource.MediaPeriodId!

The identifier of the period.

allocator: Allocator!

An Allocator from which to obtain media buffer allocations.

startPositionUs: Long

The expected start position, in microseconds.

Returns
MediaPeriod!

A new MediaPeriod.

getInitialTimeline

synchronized fun getInitialTimeline(): Timeline!

Returns the initial placeholder timeline that is returned immediately when the real timeline is not yet known, or null to let the player create an initial timeline.

Should not be called directly from application code.

The initial timeline must use the same uids for windows and periods that the real timeline will use. It also must provide windows which are marked as dynamic to indicate that the window is expected to change when the real timeline arrives.

Any media source which has multiple windows should typically provide such an initial timeline to make sure the player reports the correct number of windows immediately.

This method must be called on the application thread.

getMediaItem

fun getMediaItem(): MediaItem!

Returns the MediaItem whose media is provided by the source.

Should not be called directly from application code.

This method must be called on the application thread.

getMediaSource

synchronized fun getMediaSource(index: Int): MediaSource!

Returns the MediaSource at a specified index.

Parameters
index: Int

An index in the range of 0 <= index <= getSize.

Returns
MediaSource!

The MediaSource at this index.

getSize

synchronized fun getSize(): Int

Returns the number of media sources in the playlist.

isSingleWindow

fun isSingleWindow(): Boolean

Returns true if the media source is guaranteed to never have zero or more than one window.

Should not be called directly from application code.

The default implementation returns true.

This method must be called on the application thread.

Returns
Boolean

true if the source has exactly one window.

moveMediaSource

synchronized fun moveMediaSource(currentIndex: Int, newIndex: Int): Unit

Moves an existing MediaSource within the playlist.

Parameters
currentIndex: Int

The current index of the media source in the playlist. This index must be in the range of 0 <= index <getSize.

newIndex: Int

The target index of the media source in the playlist. This index must be in the range of 0 <= index <getSize.

moveMediaSource

synchronized fun moveMediaSource(
    currentIndex: Int,
    newIndex: Int,
    handler: Handler!,
    onCompletionAction: Runnable!
): Unit

Moves an existing MediaSource within the playlist and executes a custom action on completion.

Parameters
currentIndex: Int

The current index of the media source in the playlist. This index must be in the range of 0 <= index <getSize.

newIndex: Int

The target index of the media source in the playlist. This index must be in the range of 0 <= index <getSize.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the media source has been moved.

releasePeriod

fun releasePeriod(mediaPeriod: MediaPeriod!): Unit

Releases the period.

Should not be called directly from application code.

This method must be called on the playback thread.

Parameters
mediaPeriod: MediaPeriod!

The period to release.

removeMediaSource

synchronized fun removeMediaSource(index: Int): MediaSource!

Removes a MediaSource from the playlist.

Note: If you want to move the instance, it's preferable to use moveMediaSource instead.

Note: If you want to remove a set of contiguous sources, it's preferable to use removeMediaSourceRange instead.

Parameters
index: Int

The index at which the media source will be removed. This index must be in the range of 0 <= index <getSize.

Returns
MediaSource!

The removed MediaSource.

removeMediaSource

synchronized fun removeMediaSource(
    index: Int,
    handler: Handler!,
    onCompletionAction: Runnable!
): MediaSource!

Removes a MediaSource from the playlist and executes a custom action on completion.

Note: If you want to move the instance, it's preferable to use moveMediaSource instead.

Note: If you want to remove a set of contiguous sources, it's preferable to use removeMediaSourceRange instead.

Parameters
index: Int

The index at which the media source will be removed. This index must be in the range of 0 <= index <getSize.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the media source has been removed from the playlist.

Returns
MediaSource!

The removed MediaSource.

removeMediaSourceRange

synchronized fun removeMediaSourceRange(fromIndex: Int, toIndex: Int): Unit

Removes a range of MediaSources from the playlist, by specifying an initial index (included) and a final index (excluded).

Note: when specified range is empty, no actual media source is removed and no exception is thrown.

Parameters
fromIndex: Int

The initial range index, pointing to the first media source that will be removed. This index must be in the range of 0 <= index <= getSize.

toIndex: Int

The final range index, pointing to the first media source that will be left untouched. This index must be in the range of 0 <= index <= getSize.

Throws
java.lang.IndexOutOfBoundsException

When the range is malformed, i.e. fromIndex<0, toIndex>getSize, fromIndex>toIndex

removeMediaSourceRange

synchronized fun removeMediaSourceRange(
    fromIndex: Int,
    toIndex: Int,
    handler: Handler!,
    onCompletionAction: Runnable!
): Unit

Removes a range of MediaSources from the playlist, by specifying an initial index (included) and a final index (excluded), and executes a custom action on completion.

Note: when specified range is empty, no actual media source is removed and no exception is thrown.

Parameters
fromIndex: Int

The initial range index, pointing to the first media source that will be removed. This index must be in the range of 0 <= index <= getSize.

toIndex: Int

The final range index, pointing to the first media source that will be left untouched. This index must be in the range of 0 <= index <= getSize.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the media source range has been removed from the playlist.

Throws
java.lang.IllegalArgumentException

When the range is malformed, i.e. fromIndex<0, toIndex>getSize, fromIndex>toIndex

setShuffleOrder

synchronized fun setShuffleOrder(shuffleOrder: ShuffleOrder!): Unit

Sets a new shuffle order to use when shuffling the child media sources.

Parameters
shuffleOrder: ShuffleOrder!

A ShuffleOrder.

setShuffleOrder

synchronized fun setShuffleOrder(
    shuffleOrder: ShuffleOrder!,
    handler: Handler!,
    onCompletionAction: Runnable!
): Unit

Sets a new shuffle order to use when shuffling the child media sources.

Parameters
shuffleOrder: ShuffleOrder!

A ShuffleOrder.

handler: Handler!

The Handler to run onCompletionAction.

onCompletionAction: Runnable!

A Runnable which is executed immediately after the shuffle order has been changed.

Protected functions

disableInternal

protected fun disableInternal(): Unit

Disables the source, see disable.

enableInternal

protected fun enableInternal(): Unit

Enables the source, see enable.

getMediaPeriodIdForChildMediaPeriodId

protected fun getMediaPeriodIdForChildMediaPeriodId(
    childSourceId: ConcatenatingMediaSource.MediaSourceHolder!,
    mediaPeriodId: MediaSource.MediaPeriodId!
): MediaSource.MediaPeriodId?

Returns the MediaPeriodId in the composite source corresponding to the specified MediaPeriodId in a child source. The default implementation does not change the media period id.

Parameters
childSourceId: ConcatenatingMediaSource.MediaSourceHolder!

The unique id used to prepare the child source.

mediaPeriodId: MediaSource.MediaPeriodId!

A MediaPeriodId of the child source.

Returns
MediaSource.MediaPeriodId?

The corresponding MediaPeriodId in the composite source. Null if no corresponding media period id can be determined.

getWindowIndexForChildWindowIndex

protected fun getWindowIndexForChildWindowIndex(
    childSourceId: ConcatenatingMediaSource.MediaSourceHolder!,
    windowIndex: Int
): Int

Returns the window index in the composite source corresponding to the specified window index in a child source. The default implementation does not change the window index.

Parameters
childSourceId: ConcatenatingMediaSource.MediaSourceHolder!

The unique id used to prepare the child source.

windowIndex: Int

A window index of the child source.

Returns
Int

The corresponding window index in the composite source.

onChildSourceInfoRefreshed

protected fun onChildSourceInfoRefreshed(
    childSourceId: ConcatenatingMediaSource.MediaSourceHolder!,
    mediaSource: MediaSource!,
    newTimeline: Timeline!
): Unit

Called when the source info of a child source has been refreshed.

Parameters
childSourceId: ConcatenatingMediaSource.MediaSourceHolder!

The unique id used to prepare the child source.

mediaSource: MediaSource!

The child source whose source info has been refreshed.

newTimeline: Timeline!

The timeline of the child source.

prepareSourceInternal

synchronized protected fun prepareSourceInternal(mediaTransferListener: TransferListener?): Unit

Starts source preparation and enables the source, see prepareSource. This method is called at most once until the next call to releaseSourceInternal.

This method is called on the playback thread.

Parameters
mediaTransferListener: TransferListener?

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.

releaseSourceInternal

synchronized protected fun releaseSourceInternal(): Unit

Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.

This method is called on the playback thread.