so.kontext:video-compose adds two Compose functions, so a screen does not write the host view, the effects and the listener wiring itself.
Add the module
A player screen
show instant: keep a loaded ad in state and set it as adOnScreen at the moment.
rememberVideoAds
- Creates the episode’s
VideoAds, and a new one whencontent.idchanges. - Destroys it when the composition leaves, or when the episode changes. Destroying ends the ad on screen, a linear ad too: move to the next episode after a post-roll’s
onEnded. - A rotation recreates the composition, and with it the
VideoAds. Declareandroid:configChangesfor rotation on the Activity, or keep theVideoAdsin aViewModel(below).
VideoAdHost
- Every format. An overlay or pause ad shows where the host is placed. A linear ad is shown full screen from the Activity hosting the composition; it is never dismissed by the host, and ends by itself or by the viewer.
- The host owns the ad’s listener. Hear the ad through the host’s callbacks, not
ad.listener. - Leaving the composition dismisses an overlay or pause ad on screen.
Ads that survive a rotation
Keep theVideoAds and the ad in a ViewModel; the host shows whatever the state holds:
A vertical pager
Give each page its ownVideoAds and host; show an ad on the current page only:
INTERRUPTED), freeing the screen for the next page’s ad.
Without the module
The same, by hand: host a rememberedFrameLayout with AndroidView, call show(container) on it, set the ad’s listener in a DisposableEffect and clear it in onDispose, and destroy the VideoAds in onDispose. For a linear ad, pass the Activity hosting the composition to show(activity).