CompositeMediaSource
@UnstableApi
public abstract class CompositeMediaSource<T> extends BaseMediaSource
| java.lang.Object | ||
| ↳ | androidx.media3.exoplayer.source.BaseMediaSource | |
| ↳ | androidx.media3.exoplayer.source.CompositeMediaSource |
AdsMediaSource |
A |
ConcatenatingMediaSource2 |
Concatenates multiple |
ConcatenatingMediaSource |
This class is deprecated. Use playlist modification methods like addMediaItem instead. |
ImaServerSideAdInsertionMediaSource |
MediaSource for IMA server side inserted ad streams. |
MergingMediaSource |
Merges multiple |
WrappingMediaSource |
An abstract |
ClippingMediaSource |
|
FilteringMediaSource |
A |
LoopingMediaSource |
This class is deprecated. To loop a |
MaskingMediaSource |
A |
PreloadMediaSource |
Preloads a |
Composite MediaSource consisting of multiple child sources.
| Parameters | |
|---|---|
<T> |
The type of the id used to identify prepared child sources. |
Summary
Protected constructors |
|---|
|
Creates composite media source without child sources. |
Public methods |
|
|---|---|
void |
Throws any pending error encountered while loading or refreshing source information. |
Protected methods |
|
|---|---|
final void |
disableChildSource(@UnknownNull T id)Disables a child source. |
void |
Disables the source, see |
final void |
enableChildSource(@UnknownNull T id)Enables a child source. |
void |
Enables the source, see |
@Nullable MediaSource.MediaPeriodId |
getMediaPeriodIdForChildMediaPeriodId(Returns the |
long |
getMediaTimeForChildMediaTime(Returns the media time in the |
int |
getWindowIndexForChildWindowIndex(Returns the window index in the composite source corresponding to the specified window index in a child source. |
abstract void |
onChildSourceInfoRefreshed(Called when the source info of a child source has been refreshed. |
final void |
prepareChildSource(@UnknownNull T id, MediaSource mediaSource)Prepares a child source. |
void |
@CallSuperStarts source preparation and enables the source, see |
final void |
releaseChildSource(@UnknownNull T id)Releases a child source. |
void |
Releases the source, see |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||
|
Protected constructors
CompositeMediaSource
protected CompositeMediaSource()
Creates composite media source without child sources.
Public methods
maybeThrowSourceInfoRefreshError
@CallSuper
public void maybeThrowSourceInfoRefreshError()
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 |
Protected methods
disableChildSource
protected final void disableChildSource(@UnknownNull T id)
Disables a child source.
| Parameters | |
|---|---|
@UnknownNull T id |
The unique id used to prepare the child source. |
enableChildSource
protected final void enableChildSource(@UnknownNull T id)
Enables a child source.
| Parameters | |
|---|---|
@UnknownNull T id |
The unique id used to prepare the child source. |
getMediaPeriodIdForChildMediaPeriodId
protected @Nullable MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(
@UnknownNull T childSourceId,
MediaSource.MediaPeriodId 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 | |
|---|---|
@UnknownNull T childSourceId |
The unique id used to prepare the child source. |
MediaSource.MediaPeriodId mediaPeriodId |
A |
| Returns | |
|---|---|
@Nullable MediaSource.MediaPeriodId |
The corresponding |
getMediaTimeForChildMediaTime
protected long getMediaTimeForChildMediaTime(
@UnknownNull T childSourceId,
long mediaTimeMs,
@Nullable MediaSource.MediaPeriodId mediaPeriodId
)
Returns the media time in the MediaPeriod of the composite source corresponding to the specified media time in the MediaPeriod of the child source. The default implementation does not change the media time.
| Parameters | |
|---|---|
@UnknownNull T childSourceId |
The unique id used to prepare the child source. |
long mediaTimeMs |
A media time in the |
@Nullable MediaSource.MediaPeriodId mediaPeriodId |
The |
| Returns | |
|---|---|
long |
The corresponding media time in the |
getWindowIndexForChildWindowIndex
protected int getWindowIndexForChildWindowIndex(
@UnknownNull T childSourceId,
int windowIndex
)
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 | |
|---|---|
@UnknownNull T childSourceId |
The unique id used to prepare the child source. |
int windowIndex |
A window index of the child source. |
| Returns | |
|---|---|
int |
The corresponding window index in the composite source. |
onChildSourceInfoRefreshed
protected abstract void onChildSourceInfoRefreshed(
@UnknownNull T childSourceId,
MediaSource mediaSource,
Timeline newTimeline
)
Called when the source info of a child source has been refreshed.
| Parameters | |
|---|---|
@UnknownNull T childSourceId |
The unique id used to prepare the child source. |
MediaSource mediaSource |
The child source whose source info has been refreshed. |
Timeline newTimeline |
The timeline of the child source. |
prepareChildSource
protected final void prepareChildSource(@UnknownNull T id, MediaSource mediaSource)
Prepares a child source.
onChildSourceInfoRefreshed will be called when the child source updates its timeline with the same id passed to this method.
Any child sources that aren't explicitly released with releaseChildSource will be released in releaseSourceInternal.
| Parameters | |
|---|---|
@UnknownNull T id |
A unique id to identify the child source preparation. Null is allowed as an id. |
MediaSource mediaSource |
The child |
prepareSourceInternal
@CallSuper
protected void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)
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 | |
|---|---|
@Nullable TransferListener mediaTransferListener |
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. |
releaseChildSource
protected final void releaseChildSource(@UnknownNull T id)
Releases a child source.
| Parameters | |
|---|---|
@UnknownNull T id |
The unique id used to prepare the child source. |
releaseSourceInternal
@CallSuper
protected void releaseSourceInternal()
Releases the source, see releaseSource. This method is called exactly once after each call to prepareSourceInternal.
This method is called on the playback thread.