aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plyr.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r--src/js/plyr.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js
index dfb07302..08c608c3 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -12,6 +12,7 @@ import utils from './utils';
import Console from './console';
import Storage from './storage';
+import Ads from './plugins/ads';
import captions from './captions';
import controls from './controls';
@@ -273,6 +274,11 @@ class Plyr {
if (this.isHTML5 || (this.isEmbed && !this.supported.ui)) {
ui.build.call(this);
}
+
+ // Setup ads if provided
+ if (utils.is.url(this.config.ads.tagUrl)) {
+ this.ads = new Ads(this);
+ }
}
// ---------------------------------------
@@ -302,10 +308,21 @@ class Plyr {
}
/**
- * Play the media
+ * Play the media, or play the advertisement
*/
play() {
- return this.media.play();
+ if (utils.is.url(this.config.ads.tagUrl)) {
+ if (this.ads.playing) {
+ return;
+ }
+ if (!this.ads.initialized) {
+ this.ads.play();
+ }
+ if (!this.ads.playing) {
+ this.media.play();
+ }
+ }
+ this.media.play();
}
/**