aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plyr.js
diff options
context:
space:
mode:
authorArthur Hulsman <a.hulsman@orangegames.com>2018-03-09 11:17:24 +0100
committerArthur Hulsman <a.hulsman@orangegames.com>2018-03-09 11:17:24 +0100
commit69ffcbad27353bfd0238ba7e79e6caf3835b0efd (patch)
treee00c67db6a7741113c34c37c36166c3e427f9f6f /src/js/plyr.js
parent819f7d1080ef2748fa1c123ad0f54d075c654ab9 (diff)
downloadplyr-69ffcbad27353bfd0238ba7e79e6caf3835b0efd.tar.lz
plyr-69ffcbad27353bfd0238ba7e79e6caf3835b0efd.tar.xz
plyr-69ffcbad27353bfd0238ba7e79e6caf3835b0efd.zip
Ad block detection would not work when calling play() right after creating the player instance, so the adsManager now also rejects on such a case. Also made sure that calling play() will wait for the adsManager promise to resolve or otherwise return the media.play() method.
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r--src/js/plyr.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 9b73423e..d4c3d392 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() {
- if (this.ads.enabled && !this.ads.initialized && !this.ads.blocked) {
+ // Return the promise (for HTML5)
+ if (this.ads.enabled && !this.ads.initialized) {
this.ads.managerPromise.then(() => {
this.ads.play();
}).catch(() => {
- this.media.play();
+ return this.media.play();
});
} else {
- this.media.play();
+ return this.media.play();
}
}