private function initAdsLoader():void { ... adsLoader.addEventListener(AdErrorEvent.AD_ERROR, adsLoadErrorHandler);}private function adsLoadErrorHandler(event:AdErrorEvent):void { trace("warning", "Ads load error: " + event.error.errorMessage); videoPlayer.play();}
We’re excited to announce that we’ve teamed up with the Accelerated Mobile Pages team to bring you amp-ima-video, an IMA-SDK-enabled video player extension for AMP pages. This extension has been an AMP experiment for the past few months, but today we’re moving from experiment to public release.
amp-ima-video provides an AMP-enabled video player with the IMA SDK pre-integrated, so you can easily play and monetize content on your AMP pages. Simply provide your content URL and an ad tag, and we’ll handle playing back the video and ad(s). The extension currently supports linear in-stream single ads and VMAP playlists. To see it in action, check out the AMP by Example page for the extension.
amp-ima-video
If you have any questions or issues with the extension, please file them via the AMP issue tracker on GitHub.
MacOS High Sierra includes a new version of Safari, Safari 11. This new version by default will remove support for auto-playing videos unless they are muted. If your desktop site currently autoplays unmuted video with the IMA SDK, your users will see the first frame of the ad, but the ad will not play. To resolve this, you can either change your implementation to click-to-play, or attempt to autoplay and revert to click-to-play if that fails. We've also added a new error that will fire if the SDK is asked to autoplay an ad but is prevented from doing so by the browser. Continue reading for more info on these solutions.
The simple, advanced, and playlist IMA SDK samples use this click-to-play functionality. In short, you add a play button to your UI, and render that play button on page load. Your code should then delay calls to adDisplayContainer.initialize(), adsManager.init() and adsManager.start() until the user clicks that play button.
adDisplayContainer.initialize()
adsManager.init()
adsManager.start()
We've added a new sample to our GitHub repo, Attempt to Autoplay. This sample will autoplay ads if allowed, and if not, will follow the above click-to-play workflow. The sample starts by attempting to autoplay the content video. If autoplay succeeds, it pauses the content to play a pre-roll. This happens in an instant, so the users will not see any content actually play before the ads. If this autoplay attempt fails, the sample renders a play button and waits for the user to click that button to initialize the ad display container and play ads.
We've added AdError.ErrorCode.AUTOPLAY_DISALLOWED which the SDK will fire if it is asked to autoplay an ad but is prevented from doing so by the browser. You should not see this error if you've properly implemented one of the solutions above. This error is wrapped in a VIDEO_PLAY_ERROR; you can look for it as follows:
AdError.ErrorCode.AUTOPLAY_DISALLOWED
onAdError(adErrorEvent) { if (adErrorEvent.getError().getInnerError().getErrorCode() == google.ima.AdError.ErrorCode.AUTOPLAY_DISALLOWED) { // The browser prevented the SDK from autoplaying an ad. } }
If you have any questions, feel free to reach out to us on our support forum.
Starting with iOS 10, Safari on iPhone and iPod supports inline video playback. This opens up some new rendering options for your video player and the IMA SDK, but also introduces some caveats.
Previously, Safari on iPhone played all video in a fullscreen player. With iOS 10, Safari now supports the playsinline parameter on a video element to play that content inline.
playsinline
Fullscreen playback on iPhone Mobile Safari. The default with iOS 10+ and the only option for iOS <= 10
Inline playback on iPhone Mobile Safari. A new option in iOS 10+
On iPhone Safari, the IMA SDK re-uses your content player to play ads. We call this "custom playback." So if you add the playsinline parameter to your content video tag, IMA ads will also play inline - it's as easy as that.
Inline video playback also opens the door for the IMA SDK to play skippable ads on iPhone Mobile Safari. Previously these ads were dropped by the SDK because we could not render a skip button on top of the fullscreen player. If your player is inline, however, we can render that skip button, but there's a catch.
IMA SDK skippable ads are not supported with the "custom playback" method. To use skippable ads, you'll need to use our new API, ImaSdkSettings.setDisableCustomPlaybackForIOS10Plus(). This will cause the IMA SDK to render the ad in its own inline player on top of your content player. That player does support skippable ads. Disabling "custom playback", however, will break your fullscreen implementation for iPhone web.
ImaSdkSettings.setDisableCustomPlaybackForIOS10Plus()
The need for "custom playback" on iOS boils down to one thing - fullscreen support. Mobile Safari only supports fullscreen via videoPlayer.webkitEnterFullscreen(). In this mode, the SDK cannot render anything on top of your content player. Therefore, to support fullscreen ad playback we must use "custom playback".
videoPlayer.webkitEnterFullscreen()
Unfortunately, this is not possible on mobile Safari today - you must choose between support for skippable ads and support for fullscreen.
Prior versions of iOS (<10) do not have support for playsinline, so pages in those environments will always use "custom playback" mode, with support for fullscreen but no support for skippable ads.
That's OK! This is a complicated change with a lot of moving parts. Below is a support matrix outlining what is and is not supported based on your content player's playsinline mode and the "custom playback" mode you've set for the IMA SDK. Remember, this matrix only applies to iOS 10 and above - anything running version iOS 9 or below falls into the top left quadrant of the matrix, as this is the only option.
To help developers integrate with the IMA SDK, we're always looking for ways to provide both basic and advanced examples of features supported by the SDK. Toward this end, we're pleased to release a sample JavaScript VPAID creative and sample ad tag to aid in troubleshooting JavaScript VPAID 2.0 creatives. You can check out the new sample on GitHub, and find the new ad tag in our list of IMA sample tags as 'Sample VPAID 2.0 Linear'.
The VPAID sample plays a linear video ad and demonstrates the use of the video player proxy element required to run a VPAID ad in a secure iframe.
iframe
If you have any questions, feel free to contact us via the IMA SDK developer forum.
One of the most important factors in keeping users on your page or in your app is latency - the lower your latency, the more likely your users are to stick around. With this in mind, we'd like to remind you about our best practices for reducing latency with the IMA SDKs. In general, you can reduce latency by doing as much IMA set-up work as possible on page or app load, before your user tries to play a video. The following can be done in all of the SDKs before the user attempts to play a video:
You can find more information on optimizing latency in each of our SDKs at the links below:
As always, if you have any questions, feel free to contact us via the support forum.
On June 1, 2017, Google will cease development of Flash in the IMA SDKs. This will end support for the IMA SDK for Flash, as well as support for Flash VPAID ads in the HTML5 SDK. We strongly encourage all publishers still using the Flash SDK to migrate to the HTML5 SDK. We also strongly encourage advertisers still trafficking Flash VPAID ads to migrate those ads to JavaScript VPAID.
We will not actively prevent ad serving to the Flash SDK. However, new releases will stop after June 1st and we will no longer fix bugs or answer support questions. If ad serving or playback stops working after this date for the Flash SDK, it will not be fixed. We strongly encourage you to migrate to the HTML5 SDK.
We will no longer support Flash VPAID ads in the HTML5 SDK. Flash VPAID ads served to the HTML5 SDK will not be rendered and the SDK will fire an error. We strongly encourage you to migrate your Flash VPAID ads to JavaScript VPAID.