public final class AdsMediaSource extends CompositeMediaSource<MediaSource.MediaPeriodId>
MediaSource that inserts ads linearly with a provided content media source.| Modifier and Type | Class and Description |
|---|---|
static class |
AdsMediaSource.AdLoadException
Wrapper for exceptions that occur while loading ads, which are notified via
MediaSourceEventListener#onLoadError(int, MediaPeriodId, LoadEventInfo, MediaLoadData,
IOException, boolean). |
static interface |
AdsMediaSource.EventListener
Deprecated.
To listen for ad load error events, add a listener via
BaseMediaSource.addEventListener(Handler, MediaSourceEventListener) and check for AdsMediaSource.AdLoadExceptions in MediaSourceEventListener#onLoadError(int, MediaPeriodId,
LoadEventInfo, MediaLoadData, IOException, boolean). Individual ads loader implementations
should expose ad interaction events, if applicable. |
static interface |
AdsMediaSource.MediaSourceFactory
Factory for creating
MediaSources to play ad media. |
MediaSource.MediaPeriodId, MediaSource.SourceInfoRefreshListener| Constructor and Description |
|---|
AdsMediaSource(MediaSource contentMediaSource,
AdsMediaSource.MediaSourceFactory adMediaSourceFactory,
AdsLoader adsLoader,
android.view.ViewGroup adUiViewGroup)
Constructs a new source that inserts ads linearly with the content specified by
contentMediaSource. |
AdsMediaSource(MediaSource contentMediaSource,
AdsMediaSource.MediaSourceFactory adMediaSourceFactory,
AdsLoader adsLoader,
android.view.ViewGroup adUiViewGroup,
android.os.Handler eventHandler,
AdsMediaSource.EventListener eventListener)
Deprecated.
To listen for ad load error events, add a listener via
BaseMediaSource.addEventListener(Handler, MediaSourceEventListener) and check for AdsMediaSource.AdLoadExceptions in MediaSourceEventListener#onLoadError(int, MediaPeriodId,
LoadEventInfo, MediaLoadData, IOException, boolean). Individual ads loader implementations
should expose ad interaction events, if applicable. |
AdsMediaSource(MediaSource contentMediaSource,
DataSource.Factory dataSourceFactory,
AdsLoader adsLoader,
android.view.ViewGroup adUiViewGroup)
Constructs a new source that inserts ads linearly with the content specified by
contentMediaSource. |
AdsMediaSource(MediaSource contentMediaSource,
DataSource.Factory dataSourceFactory,
AdsLoader adsLoader,
android.view.ViewGroup adUiViewGroup,
android.os.Handler eventHandler,
AdsMediaSource.EventListener eventListener)
Deprecated.
To listen for ad load error events, add a listener via
BaseMediaSource.addEventListener(Handler, MediaSourceEventListener) and check for AdsMediaSource.AdLoadExceptions in MediaSourceEventListener#onLoadError(int, MediaPeriodId,
LoadEventInfo, MediaLoadData, IOException, boolean). Individual ads loader implementations
should expose ad interaction events, if applicable. |
| Modifier and Type | Method and Description |
|---|---|
MediaPeriod |
createPeriod(MediaSource.MediaPeriodId id,
Allocator allocator)
Returns a new
MediaPeriod identified by periodId. |
protected MediaSource.MediaPeriodId |
getMediaPeriodIdForChildMediaPeriodId(MediaSource.MediaPeriodId childId,
MediaSource.MediaPeriodId mediaPeriodId)
Returns the
MediaPeriodId in the composite source corresponding to the specified MediaPeriodId in a child source. |
protected void |
onChildSourceInfoRefreshed(MediaSource.MediaPeriodId mediaPeriodId,
MediaSource mediaSource,
Timeline timeline,
java.lang.Object manifest)
Called when the source info of a child source has been refreshed.
|
void |
prepareSourceInternal(ExoPlayer player,
boolean isTopLevelSource)
Starts source preparation.
|
void |
releasePeriod(MediaPeriod mediaPeriod)
Releases the period.
|
void |
releaseSourceInternal()
Releases the source.
|
getMediaTimeForChildMediaTime, getWindowIndexForChildWindowIndex, maybeThrowSourceInfoRefreshError, prepareChildSource, releaseChildSourceaddEventListener, createEventDispatcher, createEventDispatcher, createEventDispatcher, prepareSource, refreshSourceInfo, releaseSource, removeEventListenerpublic AdsMediaSource(MediaSource contentMediaSource, DataSource.Factory dataSourceFactory, AdsLoader adsLoader, android.view.ViewGroup adUiViewGroup)
contentMediaSource. Ad media is loaded using ExtractorMediaSource.contentMediaSource - The MediaSource providing the content to play.dataSourceFactory - Factory for data sources used to load ad media.adsLoader - The loader for ads.adUiViewGroup - A ViewGroup on top of the player that will show any ad UI.public AdsMediaSource(MediaSource contentMediaSource, AdsMediaSource.MediaSourceFactory adMediaSourceFactory, AdsLoader adsLoader, android.view.ViewGroup adUiViewGroup)
contentMediaSource.contentMediaSource - The MediaSource providing the content to play.adMediaSourceFactory - Factory for media sources used to load ad media.adsLoader - The loader for ads.adUiViewGroup - A ViewGroup on top of the player that will show any ad UI.@Deprecated public AdsMediaSource(MediaSource contentMediaSource, DataSource.Factory dataSourceFactory, AdsLoader adsLoader, android.view.ViewGroup adUiViewGroup, @Nullable android.os.Handler eventHandler, @Nullable AdsMediaSource.EventListener eventListener)
BaseMediaSource.addEventListener(Handler, MediaSourceEventListener) and check for AdsMediaSource.AdLoadExceptions in MediaSourceEventListener#onLoadError(int, MediaPeriodId,
LoadEventInfo, MediaLoadData, IOException, boolean). Individual ads loader implementations
should expose ad interaction events, if applicable.contentMediaSource. Ad media is loaded using ExtractorMediaSource.contentMediaSource - The MediaSource providing the content to play.dataSourceFactory - Factory for data sources used to load ad media.adsLoader - The loader for ads.adUiViewGroup - A ViewGroup on top of the player that will show any ad UI.eventHandler - A handler for events. May be null if delivery of events is not required.eventListener - A listener of events. May be null if delivery of events is not required.@Deprecated public AdsMediaSource(MediaSource contentMediaSource, AdsMediaSource.MediaSourceFactory adMediaSourceFactory, AdsLoader adsLoader, android.view.ViewGroup adUiViewGroup, @Nullable android.os.Handler eventHandler, @Nullable AdsMediaSource.EventListener eventListener)
BaseMediaSource.addEventListener(Handler, MediaSourceEventListener) and check for AdsMediaSource.AdLoadExceptions in MediaSourceEventListener#onLoadError(int, MediaPeriodId,
LoadEventInfo, MediaLoadData, IOException, boolean). Individual ads loader implementations
should expose ad interaction events, if applicable.contentMediaSource.contentMediaSource - The MediaSource providing the content to play.adMediaSourceFactory - Factory for media sources used to load ad media.adsLoader - The loader for ads.adUiViewGroup - A ViewGroup on top of the player that will show any ad UI.eventHandler - A handler for events. May be null if delivery of events is not required.eventListener - A listener of events. May be null if delivery of events is not required.public void prepareSourceInternal(ExoPlayer player, boolean isTopLevelSource)
BaseMediaSourceBaseMediaSource.releaseSourceInternal().prepareSourceInternal in class CompositeMediaSource<MediaSource.MediaPeriodId>player - The player for which this source is being prepared.isTopLevelSource - Whether this source has been passed directly to ExoPlayer.prepare(MediaSource) or ExoPlayer.prepare(MediaSource, boolean,
boolean).public MediaPeriod createPeriod(MediaSource.MediaPeriodId id, Allocator allocator)
MediaSourceMediaPeriod identified by periodId. This method may be called
multiple times with the same period identifier without an intervening call to
MediaSource.releasePeriod(MediaPeriod).
Should not be called directly from application code.
id - The identifier of the period.allocator - An Allocator from which to obtain media buffer allocations.MediaPeriod.public void releasePeriod(MediaPeriod mediaPeriod)
MediaSourceShould not be called directly from application code.
mediaPeriod - The period to release.public void releaseSourceInternal()
BaseMediaSourceBaseMediaSource.prepareSourceInternal(ExoPlayer, boolean).releaseSourceInternal in class CompositeMediaSource<MediaSource.MediaPeriodId>protected void onChildSourceInfoRefreshed(MediaSource.MediaPeriodId mediaPeriodId, MediaSource mediaSource, Timeline timeline, @Nullable java.lang.Object manifest)
CompositeMediaSourceonChildSourceInfoRefreshed in class CompositeMediaSource<MediaSource.MediaPeriodId>mediaPeriodId - The unique id used to prepare the child source.mediaSource - The child source whose source info has been refreshed.timeline - The timeline of the child source.manifest - The manifest of the child source.@Nullable protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId(MediaSource.MediaPeriodId childId, MediaSource.MediaPeriodId mediaPeriodId)
CompositeMediaSourceMediaPeriodId in the composite source corresponding to the specified MediaPeriodId in a child source. The default implementation does not change the media period
id.getMediaPeriodIdForChildMediaPeriodId in class CompositeMediaSource<MediaSource.MediaPeriodId>childId - The unique id used to prepare the child source.mediaPeriodId - A MediaPeriodId of the child source.MediaPeriodId in the composite source. Null if no
corresponding media period id can be determined.