aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plyr.js
diff options
context:
space:
mode:
authorSam Potts <sam@selz.com>2018-01-22 23:15:52 +1100
committerGitHub <noreply@github.com>2018-01-22 23:15:52 +1100
commit3aa5747c9018b99fe7bc1d8ad4d67cea62ae5489 (patch)
tree4278b90afa91cb8237b9faa5e50909c4ea832fc6 /src/js/plyr.js
parent6831c3053470d092c11536a837ebf8c1a8b5c530 (diff)
parent5671235fd93eac4554d2c522461df813b589a7f4 (diff)
downloadplyr-3aa5747c9018b99fe7bc1d8ad4d67cea62ae5489.tar.lz
plyr-3aa5747c9018b99fe7bc1d8ad4d67cea62ae5489.tar.xz
plyr-3aa5747c9018b99fe7bc1d8ad4d67cea62ae5489.zip
Merge pull request #760 from sampotts/beta-with-ads
Beta with ads
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();
}
/**