Tag Archives: ima_sdk
Life of a DFP Video Line Item Part II
The IMA SDK requires you to have an ad tag that points to your ad. An ad tag is a URL that returns a VAST response. The VAST (or VMAP) response contains information about your ad, including tracking URLs, clickthrough destinations, and the media files for the video ad. For more information about VAST, see the IAB website.
If you’re using DFP, the UI can generate an ad tag for you based on your line item and ad unit criteria. To generate the ad tag for your line item, follow these steps.
Now that you have your ad tag, let’s take a look at some of the parameters. We’ll use one of our standard sample tags for this exercise:
http://pubads.g.doubleclick.net/gampad/ads?
sz=640x360&
iu=/6062/iab_vast_samples/skippable&
ciu_szs=300x250,728x90&
impl=s&
env=vp&
gdfp_req=1&
output=xml_vast2&
unviewed_position_start=1&
url=[referrer_url]&
correlator=[timestamp]&
scor=[timestamp]
sz
The size of the video ad that you’re requesting.iu
Your “inventory unit” - the ad unit you created in Part I. This is in the format <network_code>/<ad_unit_code path>.ciu_szs
If your ad unit has associated companion ads, their sizes will be listed here.impl
The request mode. Here, “s” for “sync”.env
The environment. Here, “vp” for “video player”.gdfp_req
Indicates that this is a DFP request rather than the legacy Google Ads Manager.output
The type of output you want from your ad request. Typical values are “vast” or “vmap”.unviewed_position_start
Enables delayed impressions for your ad. This ensures that an impression isn’t counted until the ad starts playing.url
The URL of the page requesting ads. This will also be automatically filled in by the SDK.correlator
This randomly-generated value will be filled in by the SDK. It’s used for a number of things, but they all boil down to detecting ad requests that come from the same instance of a page load.scor
Like the correlator, but refreshed when your video stream changes rather than when the page refreshes. Used to detect ad requests that come from the same video stream instance.For more info on these parameters, see this DFP help center article.
Now that you have a basic understanding of your ad tag, it’s time to plug it into your IMA SDK implementation. If you’d like to use a video player with the SDK pre-integrated, we have pre-baked solutions for HTML5, iOS, and Android. If you want to do your own SDK integration, check out the quick start guide for Flash, HTML5, iOS, or Android. In each of the sample implementations, you’ll find a reference to at least one ad tag.
For example, the HTML5 ad tag reference is in ads.js and looks like this:
adsRequest.adTagUrl = “YOUR_AD_TAG_HERE”;Now fire up the sample and request an ad. Voila! You’ll now see the ad you trafficked in Part I serving as a pre-roll to your video content!
As always, if you have any questions feel free to contact us via the support forum.
Source: Google Ads Developer Blog
IMA SDK for Android Beta 9 Release
Required Changes
- Pause and resume ads with AdsManager
Previously, the SDK did not provide a method to pause/resume the current ad. Beta 9 of the SDK introduces AdsManager.pause() and AdsManager.resume() to control these events. You should no longer directly control the pause/play/resume of ads via your video player. Instead, use the AdsManager methods. In the future, the IMA SDK may play ads with a video player other than your content video player, so utilizing the AdsManager methods now will ensure that ad pause and resume calls are called on the appropriate player. - Change getProgress() to getAdProgress()
The VideoAdPlayer.getProgress() signature has changed; it now explicitly states it's returning the progress of the current ad:
VideoProgressUpdate getAdProgress()
When implementing this method, return VideoProgressUpdate.VIDEO_TIME_NOT_READY if an ad is not playing (for example, if content is playing). Here's a sample getAdProgress method:@Override
public VideoProgressUpdate getAdProgress() {
if (currentVideoIsAd() && currentVideo.getDuration() > 0) {
return new VideoProgressUpdate(
video.getCurrentPosition(), video.getDuration())
} else {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
}
} - Return content progress with ContentProgressProvider
For the SDK to automatically schedule ad breaks when ad rules (for DFP) or VMAP playlists are returned in an ad tag, your player should provide the playback progress of your content video. The ContentProgressProvider interface has been introduced to allow the SDK to check on actively playing content. Pass an implementation of ContentProgressProvider to your AdsRequest object via:
AdsRequest.setContentProgressProvider(ContentProgressProvider);
This method should return VideoProgressUpdate.VIDEO_TIME_NOT_READY if content is not playing (for example, if an ad is playing). Here's a sample ContentProgressProvider implementation:@Override
public VideoProgressUpdate getContentProgress() {
if (currentVideoIsContent() && currentVideo.getDuration() > 0) {
return new VideoProgressUpdate(
video.getCurrentPosition(), video.getDuration());
} else {
return VideoProgressUpdate.VIDEO_TIME_NOT_READY;
}
}
Why should I update to Beta 9?
In addition to bug fixes, Beta 9 of the SDK introduces important changes to clarify some API intentions and to, in a later release, allow the SDK to use an SDK-managed video player to play ads when it would improve the ad viewing experience for certain environments and ad types.Beta 9 is an optional upgrade; new SDK integrations should use Beta 9 (check out our quick start guide), but your existing apps can upgrade at your discretion. The API changes introduced in Beta 9 will carry over to later IMA Android SDK releases, so if you wish to minimize code changes when the next version of the IMA Android SDK is released, you can make these app code changes now.
Other changes in Beta 9
- Beta 9 also introduces Ad.getTitle, Ad.getDescription, and Ad.getContentType.
- Adds information about ad pod position to the ad UI; for example, "Ad 1 of 4: (0:13)".
- Bug fixes
Download IMA Android SDK Beta 9
You can get this latest release of the IMA Android SDK from our IMA SDK downloads page.Other questions?
As always, feel free to drop us a line on the IMA SDK forum and follow our Google+ page for other announcements and updates.Source: Google Ads Developer Blog
IMA SDK for iOS Beta 8 Release
To configure the ad UI, modify the members of the uiElements property on the adsRenderingSettings like so:
- (void)adsLoader:(IMAAdsLoader *)loader
adsLoadedWithData:(IMAAdsLoadedData *)adsLoadedData {
self.adsManager = adsLoadedData.adsManager;
// …
self.adsRenderingSettings = [[IMAAdsRenderingSettings alloc] init];
// Show no attribution or countdown timer.
self.adsRenderingSettings.uiElements = @[];
// Or, show only ad attribution.
self.adsRenderingSettings.uiElements = @[kIMAUiElements_AD_ATTRIBUTION];
// Or, show both countdown timer and ad attribution.
self.adsRenderingSettings.uiElements =
@[kIMAUiElements_AD_ATTRIBUTION, kIMAUiElements_COUNTDOWN];
// ...
[self.adsManager initializeWithContentPlayhead:self.contentPlayhead
adsRenderingSettings:self.adsRenderingSettings];
}
This configuration will not always be honored; some ad formats (e.g. AdSense and YouTube-hosted ads) require that certain UI elements be displayed. Also note that displaying the countdown timer requires ad attribution - if you want to display a countdown timer, you must also display ad attribution. You can check which UI elements are being displayed by using the uiElements property of the IMAAd object tied to the STARTED event.
As always, if you have any questions feel free to contact us via the support forum.
Source: Google Ads Developer Blog
Custom Playback Changes Now Live for the IMA HTML5 SDK
Custom playback changes
Effective today, custom playback will now be used only when necessary (e.g., on devices such as iPhones or pre-4.0 Android phones) rather than whenever a custom playback video element is passed in.
We recommend all implementations now pass in the custom playback element so that ads will be rendered via a more seamless playback experience across different environments. For more info on the change and code snippets to help you upgrade, see upgrading to the new custom playback.
Custom click tracking element changes
Custom click tracking elements will now only be used in certain video environments. To determine whether or not a custom click tracking element is being used, check ima.AdsManager.isCustomClickTrackingUsed in an AdEvent such as ima.AdEvent.STARTED. Additionally, please do not render your custom click tracking element over your video player as it will break the ad experience by preventing clickthroughs on the ad and skip button. For more information on the custom click tracking element changes, see "a note about custom click tracking elements" on our custom playback guide.
As always, if you have any questions about these changes or other IMA SDK questions, feel free to contact us via the support forum.
Source: Google Ads Developer Blog
Support for VPAID 2 JavaScript creatives in the IMA HTML5 SDK
We're pleased to announce that the IMA HTML5 SDK now supports VPAID 2 JavaScript creatives. Enabling support is as easy as including the following line before initializing your AdDisplayContainer:
google.ima.settings.setVpaidAllowed(true);
...
var adDisplayContainer = new google.ima.AdDisplayContainer(adContainerElement);
var adsLoader = new google.ima.AdsLoader(adDisplayContainer);
VPAID 2 Support caveats
There are two differences to be aware of between the VPAID 2 spec and the way the IMA SDK supports VPAID 2. These differences do not impact player or SDK implementation code, but they are important for VPAID 2 JavaScript creative authors, as creatives may throw errors or not work as expected when rendered by the IMA HTML5 SDK.
- IFrame security: The IMA SDK uses a secure iframe instead of a friendly iframe (same domain) or an in-page script to render VPAID 2 JavaScript creatives. This means that if a creative expects to access the DOM of the parent page, it could potentially cause an error.
- Video player proxy element: For security and proper mobile functionality, the IMA SDK doesn't provide the actual video element to the ad; instead, it provides a proxy element that mimics much of the functionality of the normal video element. For ad creatives that only access supported video APIs available on the proxy element, there should be no behavior changes in the rendering of the creatives. See our guide to VPAID 2 creatives for a list of supported APIs on the video proxy element.
Learn more
For more information, including a listing of what API methods are supported in the video player proxy element, check out our guide to VPAID 2 creatives.
As always, if you have any questions, feel free to contact us via the support forum.
Source: Google Ads Developer Blog
The IMA SDKs now support VAST 3
We're taking VAST 3 support out of beta and launching it as a supported feature of the IMA SDKs for Flash, HTML5, iOS, and Android. VAST 3 adds support for a host of new features, including:
- Enhanced reporting metrics and error codes.
- Customizable skip times.
- Ad podding.
- Enhanced support for adaptive bitrate creatives (e.g., HLS).
- Alternative companion creatives in HTML5 and iOS.
- Icons in HTML5.
- Companion adSlotId attribute in HTML5.
There are still a few features of VAST 3 that we will continue to add over time. Those include:
- Alternative companion creatives in Flash and Android.
- Companion adSlotId attribute in Flash, iOS, and Android.
- Standardized fallback with the fallbackOnNoAd attribute.
Your IMA SDK integration already supports VAST 3 without any code changes on your end, but you will need to adjust your serving settings. To start serving VAST 3 check out the DFP help center articles for Small Business or Premium, depending on your account type.
For more information on the features and benefits of VAST 3, check out the IAB documentation. As always, if you have any questions feel free to contact us via the support forum.
Source: Google Ads Developer Blog
Introducing the IMA SDK Plugin for Video.js
Creating a player
1. Download the video.js source and dependencies
- Grab the latest video.js player from videojs.com
- Grab the contrib-ads library from GitHub.
- Grab the IMA plugin from our GitHub repo.
npm install videojs-ima
2. Declare your video player
Make sure your html file references the required JavaScript and CSS files downloaded in step one (see the example in the README for more complete HTML). Add the following code to load the IMA SDK and declare a video player:
<script type=“text/javascript”
src=“/imasdk.googleapis.com/js/sdkloader/ima3.js”></script>
<video id="content_video" class="video-js vjs-default-skin" controls>
<source src="YOUR_VIDEO_SOURCE" type="YOUR_VIDEO_TYPE" />
</video>
3. Initialize the video player and IMA plugin
In a JavaScript block or separate JavaScript file, include the following code:
// Initialize the video.js player.
var player = videojs('content_video'); // your video tag’s id
// Declare options for the IMA plugin.
var options = {
id: 'content_video',
adTagUrl: 'YOUR_AD_TAG'
// Additional options available but not required.
// See our README for more info.
};
// Initialize the IMA plugin.
player.ima(options);
// Request ads.
player.ima.requestAds();
// Start video playback (will play ads if there is a pre-roll,
// content otherwise).
player.play();
If you have any questions, feel free to contact us via the Google Media Framework forum.
Source: Google Ads Developer Blog
Changes to Custom Playback in the IMA HTML5 SDK
Upcoming changes to custom click tracking element
What do you need to do now?
- Effective immediately, all implementation should pass in the custom playback element to ensure support of IMA video ads across all devices. Please read our guide on Upgrading to the new custom playback.
- If you are using a custom click tracking element:
- Make sure it doesn't render over your video player.
- In the ad STARTED event, show your custom tracking element if AdsManager.isCustomClickTrackingUsed() is true, and hide it otherwise.
- In the ad COMPLETE event, hide your custom tracking element if appropriate.
How can I tell if the IMA SDK is using custom playback or custom click tracking?
Release 3.1.62 of the IMA HTML5 SDK introduces AdsManager.isCustomPlaybackUsed() and AdsManager.isCustomClickTrackingUsed() which you can use in your player to see if the SDK is currently using the passed in custom video player or custom click tracking element.
As always, if you have any questions,feel free to contact us via the support forum.
Source: Google Ads Developer Blog
IMA iOS SDK beta 7 released
We've also updated our iOS sample application so you can see a working implementation of beta 7 of the IMA iOS SDK.
Why do I need to update to beta 7?
Beta 7 of the SDK introduces changes to the way video ads are displayed which will enable continued support of YouTube-hosted ads (including TrueView). Additionally, our restructuring of the SDK's API will eventually allow publishers who require a custom player (similar to the HTML5 SDK) to do so. Stay tuned for an upcoming announcement on this.
You can get this latest release of the IMA iOS SDK from our IMA downloads page.
Other questions?
As always, feel free to drop us a line on the IMA SDK forum and follow our Google+ page for other announcements and updates.