Huawei-Ima Video Ad Adapter
Hello everyone,
In this article, we will learn how to use the Huawei-Ima video ad adapter in native Android.
With this solution, you will be able to show Huawei video ads on your IMA-supported video player.
What is IMA?
Interactive Media Ads is a suite of SDKs that make it easy to integrate multimedia ads into your apps. IMA SDKs can request ads from any Vast-complaint ad server and manager ad playbacks in your app.
How does IMA work?
The IMA SDK exposes a set of APIs that allow publishers to request ads from Google Ad Manager or AdSense, interpret the ad response, and report metrics back to the ad server. Developers need to create IMA ad tag URLs to show video ads in their applications.
What is IMA Tag URL?
IMA Ad Tag URL is both used by a player to retrieve VAST or VMAP XML for showing video and audio ads. These IMA ad tags are unique URLs generated by publishers from Ad Manager. Examples and parameters could be checked from here.
- VAST Ad Tags
VAST is the standard for instructing ad tags that serve ads to video players and using XML schema. It transfers metadata from the master video ad slot.
2. VMAP Ad Tag URL
VMAP is another XML standard for serving ads to video players like VAST. VMAP supports multiple ads, contains multiple Vast Ad Tag URLs, and also has a different XML structure compared to VAST.
Huawei Ima Video Ad Adapter
Huawei Ima Video Ad Adapter is a solution where you can show Huawei Ads with a single line code instead of Google Ad in your application using Ima Ad Tag URLs that are generated from Ad Manager.
Publishers who use IMA-supported players in their application can easily integrate this adapter to show Huawei Video Ads.
The adapter covers Ima Ad Tag compatible video players in their application, such as ExoPlayer, JW Player.
How does it work?
Adapter uses Huawei VAST SDK that allows displaying VAST-based Roll ads to receive Huawei Ads. SDK request is created depending on ad tag URL parameters and configuration. Official documentation could be checked for more details about Huawei VAST SDK from here.
How to start?
- Creating an ad unit on Huawei Publisher Service.
Sign in to Huawei Developer Console and create an ad unit for Roll Ads.
2. Creating Ad Tag URL on Ad Manager Console
This step could be skipped if you already have Ad Tag URL that created from Google Ad Manager Console.
Ima ad tag URLs is created on Ad Manager by the following steps:
- Sign in to Google Ad Manager.
- Click Inventory and then Ad units.
- Locate and click your video ad unit.
- Click Generate tags.
- Complete the 3-step process and click Continue after each step (Tag type, Tag Options, and Tag Results)
- Click done.
Huawei Ima Ad Adapter uses some mandatory and optional IMA ad tag parameters to receive Huawei Ads when making requests to Huawei VAST SDK. These parameters should be considered when creating an ad tag URL on the Google Ad Manager Console.
2.1 Mandatory Parameters
output: The XML output type. VAST or VMAP.
max_ad_duration: The duration range that an ad must match. Default value will be used if this parameter is not set.
sz: The size of master video ad slot. Default value is used if this parameter is not set.
2.2. Optional Parameters
vpos: Indicates whether the ad request is being sent from pre-roll, mid-roll, or post-roll.
vad_type: Indicates whether a linear or non-linear ad should be returned.
npa: Indicates that the ad request should be treated as non-personalized.
tfcd: The ad request child-directed treatment.
All parameters could be found here:
Integrate the Huawei Ima Video Adapter SDK
In the project-level build gradle, implement Huawei’s Maven and JitPack repositories.
In the app-level build.gradle, implement adapter dependency.
All adapter versions could be checked from the following link below:
Usage of Adapter
Adapter has two different solutions depending on ExoPlayer creation method or selected IMA-supported player. These are adapter and converter solutions:
- If ExoPlayer is used and used with MediaItem to show video content and ads, an adapter solution should be chosen. Initializations of adapter are as follows:
Adapter solution could be initialized with ExoPlayer instance.
or it could be initialized with PlayerView instance.
HwImaAdapter.init() method must be called just before SimpleExoPlayer.preapare() method called.
2. If ExoPlayer is used and MediaItem is not used or, a player that is compatible with Ima Ad Tag is used, converter solution should be chosen. Initialization of converter is as follows:
If the ad creation process is successful, the TagConverterListener’s onSuccess function returns the Uri instance that contains Huawei Roll Ads. Uri object is created based on the Ad Tag URL created on the Ad Manager.
Video and ad content must be created after the callback is successful depends on the Uri instance.
After the initialization, the adapter tries to receive Huawei Ads from VAST SDK according to Ad Tag URL parameters, and if the Huawei video ad is successfully received from VAST SDK it will be shown on content instead of Google ads.
For example; if the Ad Tag URL generated in Google Ad Manager aims to display one pre-roll and two mid-roll ads on the player, also the adapter tries to show one pre-roll and two mid-roll Huawei ads on the player. If the Huawei ads receiving is fails, Google video ads will be shown instead of Huawei video ads.
Different ad positions types could be checked from the following documentation:
Currently, adapter supports only linear ads depending on the Huawei Vast SDK.
GitHub repository of adapter could be found at the following link:
Summary
In this article, we learned the implementation and logic of Huawei Video Ad Adapter and related subjects about that. Adapter could be used Ima-supported video ad players to receive Huawei Video ads.
Thank you for your time.