Class WrappingMediaSource
- java.lang.Object
-
- com.google.android.exoplayer2.source.BaseMediaSource
-
- com.google.android.exoplayer2.source.CompositeMediaSource<Void>
-
- com.google.android.exoplayer2.source.WrappingMediaSource
-
- All Implemented Interfaces:
MediaSource
- Direct Known Subclasses:
ClippingMediaSource
,FilteringMediaSource
,LoopingMediaSource
,MaskingMediaSource
@Deprecated public abstract class WrappingMediaSource extends CompositeMediaSource<Void>
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.An abstractMediaSource
wrapping a single childMediaSource
.The implementation may want to override the following methods as needed:
getMediaItem()
: Amend theMediaItem
for this media source. This is only used before the child source is prepared.onChildSourceInfoRefreshed(Timeline)
: Called whenever the child source'sTimeline
changed. ThisTimeline
can be amended if needed, for example usingForwardingTimeline
. TheTimeline
for the wrapping source needs to be published withBaseMediaSource.refreshSourceInfo(Timeline)
.createPeriod(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId, com.google.android.exoplayer2.upstream.Allocator, long)
/releasePeriod(com.google.android.exoplayer2.source.MediaPeriod)
: These methods create and releaseMediaPeriod
instances. They typically forward to the wrapped media source and optionally wrap the returnedMediaPeriod
.
Other methods like
prepareSourceInternal(com.google.android.exoplayer2.upstream.TransferListener)
,CompositeMediaSource.enableInternal()
,CompositeMediaSource.disableInternal()
orCompositeMediaSource.releaseSourceInternal()
only need to be overwritten if required for resource management.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.MediaSource
MediaSource.Factory, MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller
-
-
Field Summary
Fields Modifier and Type Field Description protected MediaSource
mediaSource
Deprecated.The wrapped childMediaSource
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
WrappingMediaSource(MediaSource mediaSource)
Deprecated.Creates the wrappingMediaSource
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MediaPeriod
createPeriod(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs)
Deprecated.Creates the requestedMediaPeriod
.protected void
disableChildSource()
Deprecated.Disables the child source.protected void
enableChildSource()
Deprecated.Enables the child source.Timeline
getInitialTimeline()
Deprecated.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.MediaItem
getMediaItem()
Deprecated.Returns theMediaItem
for this media source.protected MediaSource.MediaPeriodId
getMediaPeriodIdForChildMediaPeriodId(MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns theMediaSource.MediaPeriodId
in the wrapping source corresponding to the specifiedMediaSource.MediaPeriodId
in a child source.protected MediaSource.MediaPeriodId
getMediaPeriodIdForChildMediaPeriodId(Void childSourceId, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns theMediaSource.MediaPeriodId
in the composite source corresponding to the specifiedMediaSource.MediaPeriodId
in a child source.protected long
getMediaTimeForChildMediaTime(long mediaTimeMs)
Deprecated.Returns the media time in theMediaPeriod
of the wrapping source corresponding to the specified media time in theMediaPeriod
of the child source.protected long
getMediaTimeForChildMediaTime(Void childSourceId, long mediaTimeMs)
Deprecated.Returns the media time in theMediaPeriod
of the composite source corresponding to the specified media time in theMediaPeriod
of the child source.protected int
getWindowIndexForChildWindowIndex(int windowIndex)
Deprecated.Returns the window index in the wrapping source corresponding to the specified window index in a child source.protected int
getWindowIndexForChildWindowIndex(Void childSourceId, int windowIndex)
Deprecated.Returns the window index in the composite source corresponding to the specified window index in a child source.boolean
isSingleWindow()
Deprecated.Returns true if the media source is guaranteed to never have zero or more than one window.protected void
onChildSourceInfoRefreshed(Timeline newTimeline)
Deprecated.Called when the child source info has been refreshed.protected void
onChildSourceInfoRefreshed(Void childSourceId, MediaSource mediaSource, Timeline newTimeline)
Deprecated.Called when the source info of a child source has been refreshed.protected void
prepareChildSource()
Deprecated.Prepares the wrapped child source.protected void
prepareSourceInternal()
Deprecated.Starts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId)
.protected void
prepareSourceInternal(TransferListener mediaTransferListener)
Deprecated.Starts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId)
.protected void
releaseChildSource()
Deprecated.Releases the child source.void
releasePeriod(MediaPeriod mediaPeriod)
Deprecated.Releases aMediaPeriod
.-
Methods inherited from class com.google.android.exoplayer2.source.CompositeMediaSource
disableChildSource, disableInternal, enableChildSource, enableInternal, maybeThrowSourceInfoRefreshError, prepareChildSource, releaseChildSource, releaseSourceInternal
-
Methods inherited from class com.google.android.exoplayer2.source.BaseMediaSource
addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, enable, getPlayerId, isEnabled, prepareSource, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListener
-
-
-
-
Field Detail
-
mediaSource
protected final MediaSource mediaSource
Deprecated.The wrapped childMediaSource
.
-
-
Constructor Detail
-
WrappingMediaSource
protected WrappingMediaSource(MediaSource mediaSource)
Deprecated.Creates the wrappingMediaSource
.- Parameters:
mediaSource
- The wrapped childMediaSource
.
-
-
Method Detail
-
prepareSourceInternal
protected final void prepareSourceInternal(@Nullable TransferListener mediaTransferListener)
Deprecated.Description copied from class:BaseMediaSource
Starts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId)
. This method is called at most once until the next call toBaseMediaSource.releaseSourceInternal()
.- Overrides:
prepareSourceInternal
in classCompositeMediaSource<Void>
- Parameters:
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.
-
prepareSourceInternal
protected void prepareSourceInternal()
Deprecated.Starts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId)
. This method is called at most once until the next call toCompositeMediaSource.releaseSourceInternal()
.
-
getInitialTimeline
@Nullable public Timeline getInitialTimeline()
Deprecated.Description copied from interface:MediaSource
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.
-
isSingleWindow
public boolean isSingleWindow()
Deprecated.Description copied from interface:MediaSource
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:
- true if the source has exactly one window.
-
getMediaItem
public MediaItem getMediaItem()
Deprecated.Returns theMediaItem
for this media source.This method can be overridden to amend the
MediaItem
of the child source. It is only used before the child source is prepared.- See Also:
MediaSource.getMediaItem()
-
createPeriod
public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs)
Deprecated.Creates the requestedMediaPeriod
.This method typically forwards to the wrapped media source and optionally wraps the returned
MediaPeriod
.- Parameters:
id
- The identifier of the period.allocator
- AnAllocator
from which to obtain media buffer allocations.startPositionUs
- The expected start position, in microseconds.- Returns:
- A new
MediaPeriod
. - See Also:
MediaSource.createPeriod(MediaPeriodId, Allocator, long)
-
releasePeriod
public void releasePeriod(MediaPeriod mediaPeriod)
Deprecated.Releases aMediaPeriod
.This method typically forwards to the wrapped media source and optionally unwraps the provided
MediaPeriod
.- Parameters:
mediaPeriod
- The period to release.- See Also:
MediaSource.releasePeriod(MediaPeriod)
-
onChildSourceInfoRefreshed
protected final void onChildSourceInfoRefreshed(Void childSourceId, MediaSource mediaSource, Timeline newTimeline)
Deprecated.Description copied from class:CompositeMediaSource
Called when the source info of a child source has been refreshed.- Specified by:
onChildSourceInfoRefreshed
in classCompositeMediaSource<Void>
- Parameters:
childSourceId
- The unique id used to prepare the child source.mediaSource
- The child source whose source info has been refreshed.newTimeline
- The timeline of the child source.
-
onChildSourceInfoRefreshed
protected void onChildSourceInfoRefreshed(Timeline newTimeline)
Deprecated.Called when the child source info has been refreshed.This
Timeline
can be amended if needed, for example usingForwardingTimeline
. TheTimeline
for the wrapping source needs to be published withBaseMediaSource.refreshSourceInfo(Timeline)
.- Parameters:
newTimeline
- The timeline of the child source.
-
getWindowIndexForChildWindowIndex
protected final int getWindowIndexForChildWindowIndex(Void childSourceId, int windowIndex)
Deprecated.Description copied from class:CompositeMediaSource
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.- Overrides:
getWindowIndexForChildWindowIndex
in classCompositeMediaSource<Void>
- Parameters:
childSourceId
- The unique id used to prepare the child source.windowIndex
- A window index of the child source.- Returns:
- The corresponding window index in the composite source.
-
getWindowIndexForChildWindowIndex
protected int getWindowIndexForChildWindowIndex(int windowIndex)
Deprecated.Returns the window index in the wrapping source corresponding to the specified window index in a child source. The default implementation does not change the window index.- Parameters:
windowIndex
- A window index of the child source.- Returns:
- The corresponding window index in the wrapping source.
-
getMediaPeriodIdForChildMediaPeriodId
@Nullable protected final MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(Void childSourceId, MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Description copied from class:CompositeMediaSource
Returns theMediaSource.MediaPeriodId
in the composite source corresponding to the specifiedMediaSource.MediaPeriodId
in a child source. The default implementation does not change the media period id.- Overrides:
getMediaPeriodIdForChildMediaPeriodId
in classCompositeMediaSource<Void>
- Parameters:
childSourceId
- The unique id used to prepare the child source.mediaPeriodId
- AMediaSource.MediaPeriodId
of the child source.- Returns:
- The corresponding
MediaSource.MediaPeriodId
in the composite source. Null if no corresponding media period id can be determined.
-
getMediaPeriodIdForChildMediaPeriodId
@Nullable protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(MediaSource.MediaPeriodId mediaPeriodId)
Deprecated.Returns theMediaSource.MediaPeriodId
in the wrapping source corresponding to the specifiedMediaSource.MediaPeriodId
in a child source. The default implementation does not change the media period id.- Parameters:
mediaPeriodId
- AMediaSource.MediaPeriodId
of the child source.- Returns:
- The corresponding
MediaSource.MediaPeriodId
in the wrapping source. Null if no corresponding media period id can be determined.
-
getMediaTimeForChildMediaTime
protected final long getMediaTimeForChildMediaTime(Void childSourceId, long mediaTimeMs)
Deprecated.Description copied from class:CompositeMediaSource
Returns the media time in theMediaPeriod
of the composite source corresponding to the specified media time in theMediaPeriod
of the child source. The default implementation does not change the media time.- Overrides:
getMediaTimeForChildMediaTime
in classCompositeMediaSource<Void>
- Parameters:
childSourceId
- The unique id used to prepare the child source.mediaTimeMs
- A media time in theMediaPeriod
of the child source, in milliseconds.- Returns:
- The corresponding media time in the
MediaPeriod
of the composite source, in milliseconds.
-
getMediaTimeForChildMediaTime
protected long getMediaTimeForChildMediaTime(long mediaTimeMs)
Deprecated.Returns the media time in theMediaPeriod
of the wrapping source corresponding to the specified media time in theMediaPeriod
of the child source. The default implementation does not change the media time.- Parameters:
mediaTimeMs
- A media time in theMediaPeriod
of the child source, in milliseconds.- Returns:
- The corresponding media time in the
MediaPeriod
of the wrapping source, in milliseconds.
-
prepareChildSource
protected final void prepareChildSource()
Deprecated.Prepares the wrapped child source.onChildSourceInfoRefreshed(Timeline)
will be called when the child source updates its timeline.If sources aren't explicitly released with
releaseChildSource()
they will be released inCompositeMediaSource.releaseSourceInternal()
.
-
enableChildSource
protected final void enableChildSource()
Deprecated.Enables the child source.
-
disableChildSource
protected final void disableChildSource()
Deprecated.Disables the child source.
-
releaseChildSource
protected final void releaseChildSource()
Deprecated.Releases the child source.
-
-