Class VideoExperienceManager

  • All Implemented Interfaces:

    
    public final class VideoExperienceManager
    extends BaseExperienceManager
                        

    Manages the overall video playback experience, including the primary video and any associated companion ads.

    This class is responsible for:

    • Initializing and managing a NativeMediaPlayer for video playback.

    • Observing media events from the player and propagating them.

    • Triggering telemetry and beacon processing based on media events.

    • Loading and displaying the video content within the provided MediaView.

    • Handling video click events.

    • Managing the lifecycle and display of companion ads, if present, based on video playback milestones (e.g., second quartile, video completion).

    • 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
      Unit load() Loads and prepares the video experience.
      <Error class: unknown class> inflate(FrameLayout parentLayout) Inflates the video experience by adding the prepared media player layout to the parent view.
      Unit attachWindowLifecycleObserver(Flow<Boolean> windowFlow) Attaches a window lifecycle observer to the NativeMediaPlayer.
      Unit detachObserversAndPause() Detaches observers and pauses the video experience.
      Unit destroy() Cleans up resources used by the video experience.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • load

         Unit load()

        Loads and prepares the video experience.

        This involves:

        • Initializing the NativeMediaPlayer.

        • Loading the video content (sorting media files, preparing URLs, inflating player layout).

        • Setting up click listeners on the video view.

      • inflate

         <Error class: unknown class> inflate(FrameLayout parentLayout)

        Inflates the video experience by adding the prepared media player layout to the parent view.

        This function should be called after load has completed successfully. It takes the media player layout that was prepared during the load phase and adds it to the provided parent layout for rendering.

        Parameters:
        parentLayout - The FrameLayout parent view where the video experience will be rendered.
      • attachWindowLifecycleObserver

         Unit attachWindowLifecycleObserver(Flow<Boolean> windowFlow)

        Attaches a window lifecycle observer to the NativeMediaPlayer. This allows the media player to react to window focus changes (e.g., pause when not visible).

        Parameters:
        windowFlow - A Flow emitting true when the window is visible/focused, false otherwise.
      • detachObserversAndPause

         Unit detachObserversAndPause()

        Detaches observers and pauses the video experience.

        This function:

        • Removes click listeners from the media player layout to prevent memory leaks

        • Stops the media player

        • Cancels all active coroutine jobs

        • Clears the active jobs list