Package com.castlabs.android.adverts
Interface AdLoader
-
public interface AdLoader
The interface to provide SDK with theAd
properties The implementations are used byAdProvider.createAdLoader(AdRequest)
- Since:
- 4.2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
AdLoader.Listener
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
createMediaSource(PlayerConfig playerConfig, PlayerPlugin playerPlugin, AdLoader.Listener listener)
Asynchronously createMediaSource
to playViewGroup
getAdContainer()
Returns ad UI containerAd
getCurrentAd()
Get the currently loaded and prepared for playing Advoid
onPlayerStateChanged(boolean playWhenReady, int playbackState)
Called when the player state is changedvoid
onPositionDiscontinuity(int reason)
Called when the playback discontinuity occurslong
onSetPosition(long newPositionUs)
Called just before thePlayerController
start seeking or setting a new position.void
release()
Release any unused resourcesvoid
scheduleAd(AdRequest adRequest)
Start loading anAdRequest
.void
setPlayerController(PlayerController playerController)
Set the activePlayerController
instance ornull
if there is no activePlayerController
or it is about to be released
-
-
-
Method Detail
-
getCurrentAd
@Nullable Ad getCurrentAd()
Get the currently loaded and prepared for playing Ad- Returns:
- The current Ad or
null
-
getAdContainer
@Nullable ViewGroup getAdContainer()
Returns ad UI container- Returns:
- ad UI container
-
setPlayerController
void setPlayerController(@Nullable PlayerController playerController)
Set the activePlayerController
instance ornull
if there is no activePlayerController
or it is about to be released- Parameters:
playerController
- ThePlayerController
instance ornull
-
release
void release()
Release any unused resources
-
createMediaSource
void createMediaSource(@NonNull PlayerConfig playerConfig, @NonNull PlayerPlugin playerPlugin, @NonNull AdLoader.Listener listener)
Asynchronously createMediaSource
to play- Parameters:
playerConfig
- ThePlayerConfig
playerPlugin
- ThePlayerPlugin
listener
- The listener callback to provide the createdMediaSource
-
onSetPosition
long onSetPosition(long newPositionUs)
Called just before thePlayerController
start seeking or setting a new position. Can be used when the new position has to be adjusted by theAdLoader
implementation e.g. to do ads snap back. If the adjustment is not needed then the provided position can simply be returned.- Parameters:
newPositionUs
- The new position in microseconds- Returns:
- The adjusted position in microseconds
-
onPlayerStateChanged
void onPlayerStateChanged(boolean playWhenReady, int playbackState)
Called when the player state is changed- Parameters:
playWhenReady
- Play when ready flagplaybackState
- Playback state
-
onPositionDiscontinuity
void onPositionDiscontinuity(@DiscontinuityReason int reason)
Called when the playback discontinuity occurs- Parameters:
reason
- The reason for discontinuity
-
-