Class POBVastPlayerUtil

  • All Implemented Interfaces:

    
    public class POBVastPlayerUtil
    
                        

    An utility class for video specific classes

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static POBCompanion getSuitableEndCardCompanion(@NonNull() List<POBCompanion> companions, float playerWidthInPx, float playerHeightInPx) To find out best matching companion from list of companion using below steps Step 1: Select companion ads which have renderingMode="end-card" Step 2: if there is not companion with renderingMode="end-card" then consider existing companion list Step 3: Calculate aspect ratio for size of each companion with current vast player size (in case of video interstitial it will screen size) Step 4: Pick companion having percent value nearest to 1 or with having correction not more than +/- 0.
      static Map<String, String> generateErrorQueryParams(@NonNull() Context context, @Nullable() POBDeviceInfo deviceInfo, @Nullable() POBMediaFile suitableMediaFile) Creates a query map to pass with pubmatic vast error tracker
      static POBMediaFile filterMediaFiles(@Nullable() List<POBMediaFile> mediaFileList, @NonNull() Array<POBVideoPlayer.SupportedMediaType> supportedMediaType, int bitRate, int width, int height) Filters and returns the POBMediaFile for matching inputs.
      static int getScaleFactor(@NonNull() Context context) The scale factor of the display
      static int getBitRate(boolean isResolutionLow, boolean isWifi) Returns the bitrate for device screen scale/resolution and network.
      static double getSkipOffset(double respSkipOffset, @NonNull() POBVastPlayerConfig vastConfig, long mediaDuration) To get best possible skip offset duration for vast player to show skip on it.
      static String getCustomProductPageClickUrl(@Nullable() POBVastAd vastAd, @Nullable() String bidBundleId) Method to get custom product page url i) Check if click through url valid play store url ii) if not check if bid.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • POBVastPlayerUtil

        POBVastPlayerUtil()
    • Method Detail

      • getSuitableEndCardCompanion

        @Nullable() static POBCompanion getSuitableEndCardCompanion(@NonNull() List<POBCompanion> companions, float playerWidthInPx, float playerHeightInPx)

        To find out best matching companion from list of companion using below steps Step 1: Select companion ads which have renderingMode="end-card" Step 2: if there is not companion with renderingMode="end-card" then consider existing companion list Step 3: Calculate aspect ratio for size of each companion with current vast player size (in case of video interstitial it will screen size) Step 4: Pick companion having percent value nearest to 1 or with having correction not more than +/- 0.3 factor if any companion with above criteria is present in the provided list then return that companion else return null

        Parameters:
        companions - list of companion on which best matching algorithm is going to perform
        playerWidthInPx - Pixel width of the player
        playerHeightInPx - Pixel height of the player
        Returns:

        best matching the companion if present else return null

      • filterMediaFiles

        @Nullable() static POBMediaFile filterMediaFiles(@Nullable() List<POBMediaFile> mediaFileList, @NonNull() Array<POBVideoPlayer.SupportedMediaType> supportedMediaType, int bitRate, int width, int height)

        Filters and returns the POBMediaFile for matching inputs. returns nil if no match is found Note(Specific use case): If media file contains one of the supported media type other than webm then it does not add webm in the returning list, refer: SD-2283

        Parameters:
        mediaFileList - list of POBMediaFile objects
        supportedMediaType - Support mime type
        bitRate - expected bit rate value
        width - width of media file
        height - height of media file
        Returns:

        Returns the POBMediaFile for matching inputs

      • getScaleFactor

         static int getScaleFactor(@NonNull() Context context)

        The scale factor of the display

        Parameters:
        context - application context
        Returns:

        if density greater than equals to 2.0f returns 2 else returns 1

      • getBitRate

         static int getBitRate(boolean isResolutionLow, boolean isWifi)

        Returns the bitrate for device screen scale/resolution and network. Possible values are: Low resolution devices with WiFi : 1000 For WiFi type carrier with high resolution : 2000 else for low resolution and non-WiFi carrier : 600

        Parameters:
        isResolutionLow - true for low resolution devices else false
        isWifi - flag which indicates whether nework type is wifi or not
        Returns:

        Bit rate based on resolution and carrier type of device.

      • getSkipOffset

         static double getSkipOffset(double respSkipOffset, @NonNull() POBVastPlayerConfig vastConfig, long mediaDuration)

        To get best possible skip offset duration for vast player to show skip on it. 1. if Skip is 0 and no skipOffSet and mediaDuration is greater that maxDuration then show skip after maxDuration 2. if Skip is 0 and skipOffSet = X sec and X is less than mediaDuration then show skip after X sec else show skip after media duration 3. if Skip is 1, skipAfter= req.skipAfter and skipOffSet = X sec then show skip after skipAfter 4. if Skip is 1, skipAfter= req.x, skipMin= req.d and respSkipOffset is greater than skipMin then show skip skipAfter

        Assuming mediaDuration = 30sec &x, y >0

        Possible Cases -> expected values

        #non-skippable ads (skip = 0) respSkip = x, maxDuration = y -> Min(x,30) respSkip = 0, maxDuration = y -> Min(y,30)

        #skippable ads (skip = 1) skipAfter = 0, skipMin = 0 -> mediaDuration i.e. 30 skipAfter = 0, skipMin = 10 -> mediaDuration i.e. 30 skipAfter = x, skipMin = 0 -> Min(x,30) skipAfter = x, skipMin = 10 -> Min(x,30) skipAfter = x, skipMin = 35 -> mediaDuration i.e. 30

        Parameters:
        respSkipOffset - skip offset in the vast response
        vastConfig - the vast configuration generated from vast response
        mediaDuration - the media duration in seconds
        Returns:

        skip offset in seconds

      • getCustomProductPageClickUrl

        @Nullable() static String getCustomProductPageClickUrl(@Nullable() POBVastAd vastAd, @Nullable() String bidBundleId)

        Method to get custom product page url i) Check if click through url valid play store url ii) if not check if bid.bundle is present create url using bundle id

        Parameters:
        vastAd - instance of vastAd
        bidBundleId - bid bundle id received from response
        Returns:

        custom product page url