Class POBMediaViewRendererHelper

  • All Implemented Interfaces:
    com.pubmatic.sdk.common.utility.POBImageDownloadManager.POBImageDownloadListener

    
    public final class POBMediaViewRendererHelper
     implements POBImageDownloadManager.POBImageDownloadListener
                        

    Helper 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:

    • For bidder flow: Use mediaView directly as the media view container

    • For template flow: Add mediaView to the template's media view container

    • 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).

      • 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 assets
        bid - The bid object for rendering context
        mediaViewImageAssetId - The asset ID for the fallback image (icon or main image).
      • destroy

         final Unit destroy()

        Destroys the helper and releases all resources

      • 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