From 8348f79742a40ac465affff7527e7c22dc34cb83 Mon Sep 17 00:00:00 2001 From: ferdiemmen Date: Wed, 17 Jan 2018 08:31:36 +0100 Subject: Fix loading/playing of the ads when there is no valid ads.tagUrl --- src/js/plyr.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/js/plyr.js') diff --git a/src/js/plyr.js b/src/js/plyr.js index 2daedeac..08c608c3 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -276,7 +276,9 @@ class Plyr { } // Setup ads if provided - this.ads = new Ads(this); + if (utils.is.url(this.config.ads.tagUrl)) { + this.ads = new Ads(this); + } } // --------------------------------------- @@ -306,16 +308,21 @@ class Plyr { } /** - * Play the media + * Play the media, or play the advertisement */ play() { - if (this.ads) { - this.ads.play(); - } - - if (!this.ads.playing) { - 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(); } /** -- cgit v1.2.3