Class POBMediaViewRendererHelper
-
- All Implemented Interfaces:
-
com.pubmatic.sdk.common.utility.POBImageDownloadManager.POBImageDownloadListener
public final class POBMediaViewRendererHelper implements POBImageDownloadManager.POBImageDownloadListenerHelper class for managing media view rendering in native ads. This helper encapsulates video and image rendering logic for native ad media views, providing a reusable component for both standard rendering and SDK bidding integrations.
Key responsibilities:
Managing video asset loading via POBVideoRenderer
Managing image downloading via POBImageDownloadManager
Tracking video state (loading, rendered, complete, failed)
Managing the media view container (FrameLayout) - created internally
Forwarding video events to listeners
Usage:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePOBMediaViewRendererHelper.ListenerListener interface for media view helper callbacks
-
Field Summary
Fields Modifier and Type Field Description private final FrameLayoutmediaViewprivate POBMediaViewRendererHelper.Listenerlistener
-
Constructor Summary
Constructors Constructor Description POBMediaViewRendererHelper(Context context)
-
Method Summary
Modifier and Type Method Description final FrameLayoutgetMediaView()The media view container that holds video player or main image. final POBMediaViewRendererHelper.ListenergetListener()Listener for media view helper callbacks final UnitsetListener(POBMediaViewRendererHelper.Listener listener)Listener for media view helper callbacks final UnitloadMedia(POBNativeAdResponse nativeAdResponse, POBBid bid, Integer mediaViewImageAssetId)Loads the media assets (video and/or image) for the native ad. final Unitdestroy()Destroys the helper and releases all resources final FloatgetMediaAspectRatio()Returns the aspect ratio of the video asset with fallback to image asset. UnitonComplete(Map<String, Bitmap> downloadedImages)-
-
Constructor Detail
-
POBMediaViewRendererHelper
POBMediaViewRendererHelper(Context context)
- Parameters:
context- Valid context
-
-
Method Detail
-
getMediaView
final FrameLayout getMediaView()
The media view container that holds video player or main image. Created internally and can be used directly (bidder flow) or added to a parent container (template flow).
-
getListener
final POBMediaViewRendererHelper.Listener getListener()
Listener for media view helper callbacks
-
setListener
final Unit setListener(POBMediaViewRendererHelper.Listener listener)
Listener for media view helper callbacks
-
loadMedia
final Unit loadMedia(POBNativeAdResponse nativeAdResponse, POBBid bid, Integer mediaViewImageAssetId)
Loads the media assets (video and/or image) for the native ad. This method should be called after the native ad response is received.
- Parameters:
nativeAdResponse- The native ad response containing assetsbid- The bid object for rendering contextmediaViewImageAssetId- The asset ID for the fallback image (icon or main image).
-
getMediaAspectRatio
final Float getMediaAspectRatio()
Returns the aspect ratio of the video asset with fallback to image asset.
<p> Checks in the following order: 1. Video asset - reads from VAST player's selected media file 2. Image asset - reads dimensions from image asset For video assets, the aspect ratio is derived from the width and height attributes of the MediaFile as defined in the VAST specification. Both attributes are required. For image assets, the aspect ratio is calculated using the w and h attributes of the image/ icon asset as defined in the NATIVE ad specification. </p>- Returns:
aspect ratio as Float, or 0f if not available
-
onComplete
Unit onComplete(Map<String, Bitmap> downloadedImages)
-
-
-
-