aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/plyr.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/plyr.js')
-rw-r--r--src/js/plyr.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 7f8ad18c..04913046 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -309,13 +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;
+ // Return the promise (for HTML5)
+ if (this.ads.enabled && !this.ads.initialized) {
+ return this.ads.managerPromise.then(() => {
+ this.ads.play();
+ }).catch(() => {
+ this.media.play();
+ });
}
- // Return the promise (for HTML5)
return this.media.play();
}