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).
-
-
Constructor Summary
Constructors Constructor Description VideoExperienceManager(Context context, CoroutineScope coroutineScope, VideoExperienceModel videoExperienceModel, MutableSharedFlow<MediaEvent> mediaEventFlow, InMobiLogger logger)
-
Method Summary
Modifier and Type Method Description Unitload()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. UnitattachWindowLifecycleObserver(Flow<Boolean> windowFlow)Attaches a window lifecycle observer to the NativeMediaPlayer. UnitdetachObserversAndPause()Detaches observers and pauses the video experience. Unitdestroy()Cleans up resources used by the video experience. -
-
Constructor Detail
-
VideoExperienceManager
VideoExperienceManager(Context context, CoroutineScope coroutineScope, VideoExperienceModel videoExperienceModel, MutableSharedFlow<MediaEvent> mediaEventFlow, InMobiLogger logger)
- Parameters:
context- The Android Context.
-
-
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 emittingtruewhen the window is visible/focused,falseotherwise.
-
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
-
destroy
Unit destroy()
Cleans up resources used by the video experience. This includes destroying the NativeMediaPlayer and the CompanionAdManager.
-
-
-
-