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 abstractMediaSourcewrapping a single childMediaSource.The implementation may want to override the following methods as needed:
getMediaItem(): Amend theMediaItemfor this media source. This is only used before the child source is prepared.onChildSourceInfoRefreshed(Timeline): Called whenever the child source'sTimelinechanged. ThisTimelinecan be amended if needed, for example usingForwardingTimeline. TheTimelinefor 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 releaseMediaPeriodinstances. 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 MediaSourcemediaSourceDeprecated.The wrapped childMediaSource.
-
Constructor Summary
Constructors Modifier Constructor Description protectedWrappingMediaSource(MediaSource mediaSource)Deprecated.Creates the wrappingMediaSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MediaPeriodcreatePeriod(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs)Deprecated.Creates the requestedMediaPeriod.protected voiddisableChildSource()Deprecated.Disables the child source.protected voidenableChildSource()Deprecated.Enables the child source.TimelinegetInitialTimeline()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.MediaItemgetMediaItem()Deprecated.Returns theMediaItemfor this media source.protected MediaSource.MediaPeriodIdgetMediaPeriodIdForChildMediaPeriodId(MediaSource.MediaPeriodId mediaPeriodId)Deprecated.Returns theMediaSource.MediaPeriodIdin the wrapping source corresponding to the specifiedMediaSource.MediaPeriodIdin a child source.protected MediaSource.MediaPeriodIdgetMediaPeriodIdForChildMediaPeriodId(Void childSourceId, MediaSource.MediaPeriodId mediaPeriodId)Deprecated.Returns theMediaSource.MediaPeriodIdin the composite source corresponding to the specifiedMediaSource.MediaPeriodIdin a child source.protected longgetMediaTimeForChildMediaTime(long mediaTimeMs)Deprecated.Returns the media time in theMediaPeriodof the wrapping source corresponding to the specified media time in theMediaPeriodof the child source.protected longgetMediaTimeForChildMediaTime(Void childSourceId, long mediaTimeMs)Deprecated.Returns the media time in theMediaPeriodof the composite source corresponding to the specified media time in theMediaPeriodof the child source.protected intgetWindowIndexForChildWindowIndex(int windowIndex)Deprecated.Returns the window index in the wrapping source corresponding to the specified window index in a child source.protected intgetWindowIndexForChildWindowIndex(Void childSourceId, int windowIndex)Deprecated.Returns the window index in the composite source corresponding to the specified window index in a child source.booleanisSingleWindow()Deprecated.Returns true if the media source is guaranteed to never have zero or more than one window.protected voidonChildSourceInfoRefreshed(Timeline newTimeline)Deprecated.Called when the child source info has been refreshed.protected voidonChildSourceInfoRefreshed(Void childSourceId, MediaSource mediaSource, Timeline newTimeline)Deprecated.Called when the source info of a child source has been refreshed.protected voidprepareChildSource()Deprecated.Prepares the wrapped child source.protected voidprepareSourceInternal()Deprecated.Starts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId).protected voidprepareSourceInternal(TransferListener mediaTransferListener)Deprecated.Starts source preparation and enables the source, seeBaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId).protected voidreleaseChildSource()Deprecated.Releases the child source.voidreleasePeriod(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:BaseMediaSourceStarts 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:
prepareSourceInternalin 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:MediaSourceReturns 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:MediaSourceReturns 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 theMediaItemfor this media source.This method can be overridden to amend the
MediaItemof 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- AnAllocatorfrom 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:CompositeMediaSourceCalled when the source info of a child source has been refreshed.- Specified by:
onChildSourceInfoRefreshedin 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
Timelinecan be amended if needed, for example usingForwardingTimeline. TheTimelinefor 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:CompositeMediaSourceReturns 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:
getWindowIndexForChildWindowIndexin 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:CompositeMediaSourceReturns theMediaSource.MediaPeriodIdin the composite source corresponding to the specifiedMediaSource.MediaPeriodIdin a child source. The default implementation does not change the media period id.- Overrides:
getMediaPeriodIdForChildMediaPeriodIdin classCompositeMediaSource<Void>- Parameters:
childSourceId- The unique id used to prepare the child source.mediaPeriodId- AMediaSource.MediaPeriodIdof the child source.- Returns:
- The corresponding
MediaSource.MediaPeriodIdin 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.MediaPeriodIdin the wrapping source corresponding to the specifiedMediaSource.MediaPeriodIdin a child source. The default implementation does not change the media period id.- Parameters:
mediaPeriodId- AMediaSource.MediaPeriodIdof the child source.- Returns:
- The corresponding
MediaSource.MediaPeriodIdin 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:CompositeMediaSourceReturns the media time in theMediaPeriodof the composite source corresponding to the specified media time in theMediaPeriodof the child source. The default implementation does not change the media time.- Overrides:
getMediaTimeForChildMediaTimein classCompositeMediaSource<Void>- Parameters:
childSourceId- The unique id used to prepare the child source.mediaTimeMs- A media time in theMediaPeriodof the child source, in milliseconds.- Returns:
- The corresponding media time in the
MediaPeriodof the composite source, in milliseconds.
-
getMediaTimeForChildMediaTime
protected long getMediaTimeForChildMediaTime(long mediaTimeMs)
Deprecated.Returns the media time in theMediaPeriodof the wrapping source corresponding to the specified media time in theMediaPeriodof the child source. The default implementation does not change the media time.- Parameters:
mediaTimeMs- A media time in theMediaPeriodof the child source, in milliseconds.- Returns:
- The corresponding media time in the
MediaPeriodof 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.
-
-