MergingMediaSource
@UnstableApi
class MergingMediaSource : CompositeMediaSource
| kotlin.Any | |||
| ↳ | androidx.media3.exoplayer.source.BaseMediaSource | ||
| ↳ | androidx.media3.exoplayer.source.CompositeMediaSource | ||
| ↳ | androidx.media3.exoplayer.source.MergingMediaSource |
Merges multiple MediaSources.
The Timelines of the sources being merged must have the same number of periods.
The values of id and id are modified to start with i:, where i is the 0-based index of the MediaSource passed to the constructor that created this androidx.media3.common.TrackGroup or androidx.media3.common.Format.
Summary
Nested types |
|---|
|
Thrown when a |
@DocumentedThe reason the merge failed. |
Public constructors |
|---|
MergingMediaSource(mediaSources: Array<MediaSource!>!)Creates a merging media source. |
MergingMediaSource(Creates a merging media source. |
MergingMediaSource(Creates a merging media source. |
MergingMediaSource(Creates a merging media source. |
Public functions |
|
|---|---|
Boolean |
canUpdateMediaItem(mediaItem: MediaItem!)Returns whether the |
MediaPeriod! |
createPeriod(Returns a new |
MediaItem! |
Returns the |
Unit |
Throws any pending error encountered while loading or refreshing source information. |
Unit |
releasePeriod(mediaPeriod: MediaPeriod!)Releases the period. |
Unit |
updateMediaItem(mediaItem: MediaItem!)Updates the |
Protected functions |
|
|---|---|
MediaSource.MediaPeriodId? |
getMediaPeriodIdForChildMediaPeriodId(Returns the |
Unit |
onChildSourceInfoRefreshed(Called when the source info of a child source has been refreshed. |
Unit |
prepareSourceInternal(mediaTransferListener: TransferListener?)Starts source preparation and enables the source, see |
Unit |
Releases the source, see |
Inherited functions |
||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
Public constructors
MergingMediaSource
MergingMediaSource(mediaSources: Array<MediaSource!>!)
Creates a merging media source.
Neither offsets between the timestamps in the media sources nor the durations of the media sources will be adjusted.
| Parameters | |
|---|---|
mediaSources: Array<MediaSource!>! |
The |
MergingMediaSource
MergingMediaSource(
adjustPeriodTimeOffsets: Boolean,
mediaSources: Array<MediaSource!>!
)
Creates a merging media source.
Durations of the media sources will not be adjusted.
| Parameters | |
|---|---|
adjustPeriodTimeOffsets: Boolean |
Whether to adjust timestamps of the merged media sources to all start at the same time. |
mediaSources: Array<MediaSource!>! |
The |
MergingMediaSource
MergingMediaSource(
adjustPeriodTimeOffsets: Boolean,
clipDurations: Boolean,
mediaSources: Array<MediaSource!>!
)
Creates a merging media source.
| Parameters | |
|---|---|
adjustPeriodTimeOffsets: Boolean |
Whether to adjust timestamps of the merged media sources to all start at the same time. |
clipDurations: Boolean |
Whether to clip the durations of the media sources to match the shortest duration. |
mediaSources: Array<MediaSource!>! |
The |
MergingMediaSource
MergingMediaSource(
adjustPeriodTimeOffsets: Boolean,
clipDurations: Boolean,
compositeSequenceableLoaderFactory: CompositeSequenceableLoaderFactory!,
mediaSources: Array<MediaSource!>!
)
Creates a merging media source.
| Parameters | |
|---|---|
adjustPeriodTimeOffsets: Boolean |
Whether to adjust timestamps of the merged media sources to all start at the same time. |
clipDurations: Boolean |
Whether to clip the durations of the media sources to match the shortest duration. |
compositeSequenceableLoaderFactory: CompositeSequenceableLoaderFactory! |
A factory to create composite |
mediaSources: Array<MediaSource!>! |
The |
Public functions
canUpdateMediaItem
fun canUpdateMediaItem(mediaItem: MediaItem!): Boolean
Returns whether the MediaItem for this source can be updated with the provided item.
Should not be called directly from application code.
This method must be called on the application thread.
| Returns | |
|---|---|
Boolean |
Whether the source can be updated using this item. |
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 |
startPositionUs: Long |
The expected start position, in microseconds. |
| Returns | |
|---|---|
MediaPeriod! |
A new |
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.
maybeThrowSourceInfoRefreshError
fun maybeThrowSourceInfoRefreshError(): Unit
Throws any pending error encountered while loading or refreshing source information.
Should not be called directly from application code.
This method must be called on the playback thread and only after prepareSource.
| Throws | |
|---|---|
java.io.IOException |
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. |
updateMediaItem
fun updateMediaItem(mediaItem: MediaItem!): Unit
Updates the MediaItem for this source.
Should not be called directly from application code.
This method must be called on the playback thread and only if canUpdateMediaItem returns true for the new MediaItem.
Protected functions
getMediaPeriodIdForChildMediaPeriodId
protected fun getMediaPeriodIdForChildMediaPeriodId(
childSourceId: Int!,
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: Int! |
The unique id used to prepare the child source. |
mediaPeriodId: MediaSource.MediaPeriodId! |
A |
| Returns | |
|---|---|
MediaSource.MediaPeriodId? |
The corresponding |
onChildSourceInfoRefreshed
protected fun onChildSourceInfoRefreshed(
childSourceId: Int!,
mediaSource: MediaSource!,
newTimeline: Timeline!
): Unit
Called when the source info of a child source has been refreshed.
| Parameters | |
|---|---|
childSourceId: Int! |
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
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
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.