aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/plugins/ads.js9
-rw-r--r--src/js/plyr.js11
-rw-r--r--src/js/utils.js2
3 files changed, 13 insertions, 9 deletions
diff --git a/src/js/plugins/ads.js b/src/js/plugins/ads.js
index 8c9baf71..dd942b49 100644
--- a/src/js/plugins/ads.js
+++ b/src/js/plugins/ads.js
@@ -18,10 +18,11 @@ class Ads {
this.player = player;
this.playing = false;
this.initialized = false;
+ this.enabled = utils.is.url(player.config.ads.tagUrl);
// Check if a tag URL is provided.
- if (!utils.is.url(player.config.ads.tagUrl)) {
- return this;
+ if (!this.enabled) {
+ return;
}
// Check if the Google IMA3 SDK is loaded
@@ -456,7 +457,9 @@ class Ads {
*/
cancel() {
// Pause our video
- this.resumeContent();
+ if (this.initialized) {
+ this.resumeContent();
+ }
// Tell our instance that we're done for now
this.handleEventListeners('ERROR');
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 9a3c0afb..3d0f79a7 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
-// plyr.js v3.0.0-beta.4
+// plyr.js v3.0.0-beta.5
// https://github.com/sampotts/plyr
// License: The MIT License (MIT)
// ==========================================================================
@@ -276,9 +276,7 @@ class Plyr {
}
// Setup ads if provided
- if (utils.is.url(this.config.ads.tagUrl)) {
- this.ads = new Ads(this);
- }
+ this.ads = new Ads(this);
}
// ---------------------------------------
@@ -311,17 +309,20 @@ class Plyr {
* Play the media, or play the advertisement
*/
play() {
- if (utils.is.url(this.config.ads.tagUrl)) {
+ if (this.ads.enabled) {
if (this.ads.playing) {
return;
}
+
if (!this.ads.initialized) {
this.ads.play();
}
+
if (!this.ads.playing) {
this.media.play();
}
}
+
this.media.play();
}
diff --git a/src/js/utils.js b/src/js/utils.js
index abc2a89a..155dc087 100644
--- a/src/js/utils.js
+++ b/src/js/utils.js
@@ -614,7 +614,7 @@ const utils = {
formatTime(time = 0, displayHours = false, inverted = false) {
// Bail if the value isn't a number
if (!utils.is.number(time)) {
- return;
+ return this.formatTime(null, displayHours, inverted);
}
// Format time component to add leading zero