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.
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user