From 9ce5e8c11d176242ae9af9a03c06e32b6dab2c4a Mon Sep 17 00:00:00 2001 From: Shawn Busolits Date: Thu, 8 Mar 2018 15:22:50 -0500 Subject: [PATCH] Publishing latest changes --- attempt_to_autoplay/ads.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/attempt_to_autoplay/ads.js b/attempt_to_autoplay/ads.js index c4bc5d2..870cf88 100755 --- a/attempt_to_autoplay/ads.js +++ b/attempt_to_autoplay/ads.js @@ -101,10 +101,16 @@ function setUpIMA() { // An event listener to tell the SDK that our content video // is completed so the SDK can play any post-roll ads. - var contentEndedListener = function() {adsLoader.contentComplete();}; videoContent.onended = contentEndedListener; } +function contentEndedListener() { + videoContent.onended = null; + if (adsLoader) { + adsLoader.contentComplete(); + } +} + function autoplayChecksResolved() { // Request video ads. var adsRequest = new google.ima.AdsRequest(); @@ -214,9 +220,10 @@ function onAdError(adErrorEvent) { function onContentPauseRequested() { videoContent.pause(); + videoContent.onended = null; } function onContentResumeRequested() { videoContent.play(); - + videoContent.onended = contentEndedListener; }