Class HybridVideoExperienceManager
-
- All Implemented Interfaces:
public final class HybridVideoExperienceManagerManages the lifecycle and experience of a hybrid HTML video ad. This class acts as a bridge between the RenderView (hosting the ad) and the HtmlMediaPlayer (handling video playback), coordinating loading, inflation, playback control, and event handling.
-
-
Field Summary
Fields Modifier and Type Field Description private final <Error class: unknown class>hybridPlayerScopeprivate HtmlMediaPlayermediaPlayer
-
Constructor Summary
Constructors Constructor Description HybridVideoExperienceManager(RenderView renderView, AdConfig.HybridNativeConfig hybridNativeConfig, HtmlVideoPlayerRequest videoRequestConfig, HtmlVideoEventsListener videoPlaybackListener, RenderViewTelemetryManager telemetryManager, InMobiLogger logger)
-
Method Summary
Modifier and Type Method Description final <Error class: unknown class>getHybridPlayerScope()Dedicated scope separation: IO for background + main for UI final HtmlMediaPlayergetMediaPlayer()final UnitsetMediaPlayer(HtmlMediaPlayer mediaPlayer)final Booleanload(HtmlVideoLoadListener videoLoadListener)Loads video assets into the underlying HtmlMediaPlayer. final Unitinflate(ViewGroup parentView)Inflates (attaches) the video container view to the supplied parent view and starts the player, which may begin playback if autoplay is enabled. final UnitimpressionFired()Notifies the OMID ad session that an impression has occurred. final Unitclicked()final BooleanhandleVideoPlayerActions(VideoPlayerActions action)Handles function calls originating from the JavaScript layer of the ad creative. final BooleanupdateVideoPosition(VideoViewPosition newVideoViewPosition)Updates the on-screen position and dimensions of the video player view. final BooleanplayVideo()Starts or resumes video playback. final BooleanpauseVideo()Pauses active video playback. final BooleanhandleMute(Boolean mute)Mutes or unmutes the player's audio. final BooleanhandleShowPlayer(Boolean show)Shows or hides the player view. final HtmlVideoPlaybackStategetPlaybackState()Retrieves a snapshot of the current video playback state. final UnithandleVisibilityChange(Boolean isViewable)Propagates viewability changes from the hosting RenderView to the media player, allowing it to automatically pause or resume playback based on visibility. final UnithandleOnWindowVisible()Called when the ad container becomes visible on screen. final UnithandleOnWindowGone()Called when the ad container is no longer visible on screen. final OmidTrackedHybridVideoAdgetOMIDTrackedAd(AdContainer adContainer, ViewableAd viewableAd, TrackerAttr trackerAttr, String contentUrl)Creates an OMID-tracked ad wrapper for hybrid video ads. final Unitdestroy()Releases all resources, stops playback, and terminates all coroutine scopes. final UnitdestroyVideoPlayer()-
-
Constructor Detail
-
HybridVideoExperienceManager
HybridVideoExperienceManager(RenderView renderView, AdConfig.HybridNativeConfig hybridNativeConfig, HtmlVideoPlayerRequest videoRequestConfig, HtmlVideoEventsListener videoPlaybackListener, RenderViewTelemetryManager telemetryManager, InMobiLogger logger)
- Parameters:
renderView- The RenderView hosting the hybrid video ad.hybridNativeConfig- Configuration parameters for hybrid native ads.videoRequestConfig- Configuration for the HTML video player request.videoPlaybackListener- Listener for video playback events.telemetryManager- Optional telemetry manager for reporting events.logger- Optional logger for debugging and error reporting.
-
-
Method Detail
-
getHybridPlayerScope
final <Error class: unknown class> getHybridPlayerScope()
Dedicated scope separation: IO for background + main for UI
-
getMediaPlayer
final HtmlMediaPlayer getMediaPlayer()
-
setMediaPlayer
final Unit setMediaPlayer(HtmlMediaPlayer mediaPlayer)
-
load
final Boolean load(HtmlVideoLoadListener videoLoadListener)
Loads video assets into the underlying HtmlMediaPlayer. This initiates video pre-caching and preparation for playback.
- Parameters:
videoLoadListener- A listener to be notified of video load success or failure.
-
inflate
final Unit inflate(ViewGroup parentView)
Inflates (attaches) the video container view to the supplied parent view and starts the player, which may begin playback if autoplay is enabled.
- Parameters:
parentView- The ViewGroup to which the player view will be added.
-
impressionFired
final Unit impressionFired()
Notifies the OMID ad session that an impression has occurred.
-
handleVideoPlayerActions
final Boolean handleVideoPlayerActions(VideoPlayerActions action)
Handles function calls originating from the JavaScript layer of the ad creative.
- Returns:
A result value if the function is expected to return one (e.g.,
getPlaybackState), otherwise null.
-
updateVideoPosition
final Boolean updateVideoPosition(VideoViewPosition newVideoViewPosition)
Updates the on-screen position and dimensions of the video player view.
- Parameters:
newVideoViewPosition- The new position and size to apply.
-
pauseVideo
final Boolean pauseVideo()
Pauses active video playback.
-
handleMute
final Boolean handleMute(Boolean mute)
Mutes or unmutes the player's audio.
- Parameters:
mute-trueto mute,falseto unmute.
-
handleShowPlayer
final Boolean handleShowPlayer(Boolean show)
Shows or hides the player view.
- Parameters:
show-trueto make the player visible,falseto hide it.
-
getPlaybackState
final HtmlVideoPlaybackState getPlaybackState()
Retrieves a snapshot of the current video playback state.
- Returns:
An HtmlVideoPlaybackState object with current playback details.
-
handleVisibilityChange
final Unit handleVisibilityChange(Boolean isViewable)
Propagates viewability changes from the hosting RenderView to the media player, allowing it to automatically pause or resume playback based on visibility.
- Parameters:
isViewable-trueif the ad container is visible,falseotherwise.
-
handleOnWindowVisible
final Unit handleOnWindowVisible()
Called when the ad container becomes visible on screen. Resumes playback only if the last tracked state was paused.
-
handleOnWindowGone
final Unit handleOnWindowGone()
Called when the ad container is no longer visible on screen. Stops playback and all associated tracking.
-
getOMIDTrackedAd
final OmidTrackedHybridVideoAd getOMIDTrackedAd(AdContainer adContainer, ViewableAd viewableAd, TrackerAttr trackerAttr, String contentUrl)
Creates an OMID-tracked ad wrapper for hybrid video ads.
- Parameters:
adContainer- The container holding the ad.viewableAd- The base viewable ad instance.trackerAttr- Attributes for the OMID tracker.contentUrl- The URL of the ad content.- Returns:
An OmidTrackedHybridVideoAd instance, or null if creation fails.
-
destroy
final Unit destroy()
Releases all resources, stops playback, and terminates all coroutine scopes. This must be called to prevent memory leaks when the ad is destroyed.
-
destroyVideoPlayer
final Unit destroyVideoPlayer()
-
-
-
-