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.
Click-to-play
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.
Attempt to autoplay
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.
New error for failed autoplay
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:
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 .
- Shawn Busolits , IMA SDK Team