aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plugins/ads.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2019-02-01 00:24:48 +1100
committerSam Potts <sam@potts.es>2019-02-01 00:24:48 +1100
commiteb628c8e4f109bb6aa4dc9196ee8f075092b225e (patch)
tree36c71f639a06c0c96d2bc9655d6c162ca03a3fca /src/js/plugins/ads.js
parentd0e3c7c6d00d66ea2dc8533e68aa0af0ca952d1d (diff)
downloadplyr-eb628c8e4f109bb6aa4dc9196ee8f075092b225e.tar.lz
plyr-eb628c8e4f109bb6aa4dc9196ee8f075092b225e.tar.xz
plyr-eb628c8e4f109bb6aa4dc9196ee8f075092b225e.zip
Ads bug fixes
Diffstat (limited to 'src/js/plugins/ads.js')
-rw-r--r--src/js/plugins/ads.js19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js
index c643c5dd..74e21d3c 100644
--- a/src/js/plugins/ads.js
+++ b/src/js/plugins/ads.js
@@ -136,6 +136,7 @@ class Ads {
this.elements.container = createElement('div', {
class: this.player.config.classNames.ads,
});
+
this.player.elements.container.appendChild(this.elements.container);
// So we can run VPAID2
@@ -144,9 +145,11 @@ class Ads {
// Set language
google.ima.settings.setLocale(this.player.config.ads.language);
- // We assume the adContainer is the video container of the plyr element
- // that will house the ads
- this.elements.displayContainer = new google.ima.AdDisplayContainer(this.elements.container);
+ // Set playback for iOS10+
+ google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playsinline);
+
+ // We assume the adContainer is the video container of the plyr element that will house the ads
+ this.elements.displayContainer = new google.ima.AdDisplayContainer(this.elements.container, this.player.media);
// Request video ads to be pre-loaded
this.requestAds();
@@ -488,10 +491,8 @@ class Ads {
// Ad is stopped
this.playing = false;
- // Play our video
- if (this.player.currentTime < this.player.duration) {
- this.player.play();
- }
+ // Play video
+ this.player.media.play();
}
/**
@@ -501,11 +502,11 @@ class Ads {
// Show the advertisement container
this.elements.container.style.zIndex = 3;
- // Ad is playing.
+ // Ad is playing
this.playing = true;
// Pause our video.
- this.player.pause();
+ this.player.media.pause();
}
/**