diff options
author | Arthur Hulsman <a.hulsman@orangegames.com> | 2018-03-06 17:27:59 +0100 |
---|---|---|
committer | Arthur Hulsman <a.hulsman@orangegames.com> | 2018-03-06 17:27:59 +0100 |
commit | e90a603d57836f6b8962a661b4668fd81c9b72a4 (patch) | |
tree | 3bb95ed46039770106139ea2dbf1e7957a6f1b31 /src/js/plyr.js | |
parent | 6f061621ad64eefd0e831b8e1372ca665a130d5c (diff) | |
download | plyr-e90a603d57836f6b8962a661b4668fd81c9b72a4.tar.lz plyr-e90a603d57836f6b8962a661b4668fd81c9b72a4.tar.xz plyr-e90a603d57836f6b8962a661b4668fd81c9b72a4.zip |
Removed a double this.enabled variable and updated a comment in ads.js. Also made sure the adsmanager promise also can fail, so we can use it to wait for getting the advertisement ready when someone clicks the play button. Otherwise there it can look glitchy when the actual video starts playing and the video ad plays a few seconds later because the vast tag was slow to retrieve. Also fixed a typo.
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r-- | src/js/plyr.js | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js index 7f8ad18c..9b73423e 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -309,14 +309,15 @@ class Plyr { * Play the media, or play the advertisement (if they are not blocked) */ play() { - // TODO: Always return a promise? if (this.ads.enabled && !this.ads.initialized && !this.ads.blocked) { - this.ads.play(); - return null; + this.ads.managerPromise.then(() => { + this.ads.play(); + }).catch(() => { + this.media.play(); + }); + } else { + this.media.play(); } - - // Return the promise (for HTML5) - return this.media.play(); } /** |