Class MediaViewManager
-
- All Implemented Interfaces:
public final class MediaViewManagerManages the lifecycle and display of media experiences within a MediaView.
This class is responsible for creating and managing an BaseExperienceManager which handles the loading, inflation, and display of media content based on an ExperienceModel. It also provides a flow of MediaEvents to communicate media-related events to the client.
-
-
Field Summary
Fields Modifier and Type Field Description private final Flow<MediaEvent>mediaEventFlow
-
Constructor Summary
Constructors Constructor Description MediaViewManager(Context context, CoroutineScope coroutineScope, InMobiLogger logger)
-
Method Summary
Modifier and Type Method Description final Flow<MediaEvent>getMediaEventFlow()A shared flow that emits MediaEvents related to the media experience. final MediaViewload(ExperienceModel experienceModel)Inflates the media experience based on the provided ExperienceModel. final UnitattachWindowLifecycleObserver(Flow<Boolean> windowFlow)Attaches a window lifecycle observer to the BaseExperienceManager. final UnitdetachObserversAndPause()Detaches window lifecycle observers and pauses the media experience. final <Error class: unknown class>destroy()Destroys the BaseExperienceManager and releases any associated resources. -
-
Constructor Detail
-
MediaViewManager
MediaViewManager(Context context, CoroutineScope coroutineScope, InMobiLogger logger)
- Parameters:
context- The application context.coroutineScope- The coroutine scope used for asynchronous operations.logger- An optional InMobiLogger instance for logging.
-
-
Method Detail
-
getMediaEventFlow
final Flow<MediaEvent> getMediaEventFlow()
A shared flow that emits MediaEvents related to the media experience.
-
load
final MediaView load(ExperienceModel experienceModel)
Inflates the media experience based on the provided ExperienceModel.
This function creates an BaseExperienceManager using the ExperienceManagerFactory, then inflates the media content within the MediaView. This is a suspend function that performs its work on the Dispatchers.IO dispatcher.
- Parameters:
experienceModel- The ExperienceModel that defines the media experience to be inflated.- Returns:
The MediaView containing the inflated media experience.
-
attachWindowLifecycleObserver
final Unit attachWindowLifecycleObserver(Flow<Boolean> windowFlow)
Attaches a window lifecycle observer to the BaseExperienceManager.
This allows the BaseExperienceManager to react to changes in the window's lifecycle, such as when the window becomes visible or hidden.
- Parameters:
windowFlow- A flow of Boolean values indicating whether the window is visible (true) or not (false).
-
detachObserversAndPause
final Unit detachObserversAndPause()
Detaches window lifecycle observers and pauses the media experience.
This method should be called when the media experience should be paused, such as when the containing view goes out of focus or becomes non-visible. It stops any ongoing media playback and tracking to conserve resources.
-
destroy
final <Error class: unknown class> destroy()
Destroys the BaseExperienceManager and releases any associated resources.
This should be called when the media experience is no longer needed to prevent memory leaks and ensure proper cleanup.
-
-
-
-