Class VideoSurfaceViewabilityController

  • All Implemented Interfaces:

    
    public final class VideoSurfaceViewabilityController
    
                        

    A 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.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Job init(SurfaceViewabilityListener surfaceViewabilityListener) Starts the viewability tracking process.
      final Unit startObserversAndResume() Starts observing viewability and resumes tracking.
      final Unit detachObserversAndPause() Detaches viewability observers and pauses tracking.
      final Unit onVideoComplete() Called when the video playback is complete.
      final Unit release() Releases resources held by this controller.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 playVideo callback on the SurfaceViewabilityListener. When it's not viewable, it triggers the pauseVideo callback.

      • 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.

      • release

         final Unit release()

        Releases resources held by this controller. This method stops the viewability tracker and releases the surface.