Package com.castlabs.android.adverts
Class ServerAdLoader
java.lang.Object
com.castlabs.android.adverts.ServerAdLoader
- All Implemented Interfaces:
AdLoader
Base class for server-side ad loaders that operate on top of the content media source instead of
providing a custom media source hook.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.castlabs.android.adverts.AdLoader
AdLoader.Listener -
Method Summary
Modifier and TypeMethodDescriptionfinal voidcreateMediaSource(PlayerConfig playerConfig, PlayerPlugin playerPlugin, AdLoader.Listener listener) Asynchronously createMediaSourceto playReturns ad UI containervoidonContentMediaSource(PlayerConfig playerConfig, com.google.android.exoplayer2.source.MediaSource mediaSource) Notifies the loader of the contentMediaSourcethat will be used for playback.voidrelease()Release any unused resourcesfinal booleanIndicates whether this loader needs to create its own media source (client-side ads) or whether it operates on the content media source prepared by the player (server-side ads).voidscheduleAd(AdRequest adRequest) Start loading anAdRequest.voidsetPlayerController(PlayerController playerController) Set the activePlayerControllerinstance ornullif there is no activePlayerControlleror it is about to be releasedMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.castlabs.android.adverts.AdLoader
getAdApi, getAdPositionMs, getCurrentAd, maybeWrapMediaSource, onPlayerStateChanged, onPositionDiscontinuity, onSetPosition
-
Method Details
-
getAdContainer
Description copied from interface:AdLoaderReturns ad UI container- Specified by:
getAdContainerin interfaceAdLoader- Returns:
- ad UI container
-
setPlayerController
Description copied from interface:AdLoaderSet the activePlayerControllerinstance ornullif there is no activePlayerControlleror it is about to be released- Specified by:
setPlayerControllerin interfaceAdLoader- Parameters:
playerController- ThePlayerControllerinstance ornull
-
release
@CallSuper public void release()Description copied from interface:AdLoaderRelease any unused resources -
requiresMediaSourceHook
public final boolean requiresMediaSourceHook()Description copied from interface:AdLoaderIndicates whether this loader needs to create its own media source (client-side ads) or whether it operates on the content media source prepared by the player (server-side ads).- Specified by:
requiresMediaSourceHookin interfaceAdLoader- Returns:
trueif a media-source hook is required,falseotherwise.
-
createMediaSource
public final void createMediaSource(@NonNull PlayerConfig playerConfig, @NonNull PlayerPlugin playerPlugin, @NonNull AdLoader.Listener listener) Description copied from interface:AdLoaderAsynchronously createMediaSourceto play- Specified by:
createMediaSourcein interfaceAdLoader- Parameters:
playerConfig- ThePlayerConfigplayerPlugin- ThePlayerPluginlistener- The listener callback to provide the createdMediaSource
-
scheduleAd
Description copied from interface:AdLoaderStart loading anAdRequest. This may be also called during playback. Support for on-request ad scheduling depends on the AdLoader implementation.- Specified by:
scheduleAdin interfaceAdLoader- Parameters:
adRequest- The ad request to perform.
-
onContentMediaSource
public void onContentMediaSource(@NonNull PlayerConfig playerConfig, @NonNull com.google.android.exoplayer2.source.MediaSource mediaSource) Description copied from interface:AdLoaderNotifies the loader of the contentMediaSourcethat will be used for playback. This is invoked only for loaders that do not require a media-source hook.- Specified by:
onContentMediaSourcein interfaceAdLoader- Parameters:
playerConfig- ThePlayerConfigassociated with the media source.mediaSource- The content media source that will be prepared.
-