Class VideoSurfaceViewabilityController
-
- All Implemented Interfaces:
public final class VideoSurfaceViewabilityControllerA controller responsible for managing the viewability of a video surface.
This class handles the lifecycle of a video surface, including its attachment and detachment, and tracks the viewability of the video using a VideoPlayerViewableTracker. It also manages the playback state of the video based on its viewability.
-
-
Constructor Summary
Constructors Constructor Description VideoSurfaceViewabilityController(CoroutineScope coroutineScope, MediaPlayer mediaPlayer, RelativeLayout mediaPlayerLayout, VideoPlayerConfig config, InMobiLogger logger)
-
Method Summary
Modifier and Type Method Description final Jobinit(SurfaceViewabilityListener surfaceViewabilityListener)Starts the viewability tracking process. final UnitstartObserversAndResume()Starts observing viewability and resumes tracking. final UnitdetachObserversAndPause()Detaches viewability observers and pauses tracking. final UnitonVideoComplete()Called when the video playback is complete. final Unitrelease()Releases resources held by this controller. -
-
Constructor Detail
-
VideoSurfaceViewabilityController
VideoSurfaceViewabilityController(CoroutineScope coroutineScope, MediaPlayer mediaPlayer, RelativeLayout mediaPlayerLayout, VideoPlayerConfig config, InMobiLogger logger)
-
-
Method Detail
-
init
final Job init(SurfaceViewabilityListener surfaceViewabilityListener)
Starts the viewability tracking process.
This method initializes the texture view, starts tracking the viewability, and sets up the listener for viewability changes.
- Parameters:
surfaceViewabilityListener- The SurfaceViewabilityListener for receiving viewability events.
-
startObserversAndResume
final Unit startObserversAndResume()
Starts observing viewability and resumes tracking.
This method sets the controller as active, resumes the viewability tracker if conditions allow, and starts collecting viewability status updates. When the video becomes viewable, it triggers the
playVideocallback on the SurfaceViewabilityListener. When it's not viewable, it triggers thepauseVideocallback.
-
detachObserversAndPause
final Unit detachObserversAndPause()
Detaches viewability observers and pauses tracking.
This method sets the controller as inactive, stops the viewability tracker, and cancels any active jobs related to viewability tracking.
-
onVideoComplete
final Unit onVideoComplete()
Called when the video playback is complete. This method stops the viewability tracker.
-
-
-
-