Noticed that Plyr stopped working when ads are blocked.

This commit is contained in:
Arthur Hulsman 2018-01-18 14:04:47 +01:00
parent 8af312fe3c
commit ed6048034b

View File

@ -33,7 +33,6 @@ class Ads {
* Get the ads instance ready. * Get the ads instance ready.
*/ */
ready() { ready() {
this.time = Date.now();
this.adsContainer = null; this.adsContainer = null;
this.adDisplayContainer = null; this.adDisplayContainer = null;
this.adsManager = null; this.adsManager = null;
@ -366,11 +365,15 @@ class Ads {
play() { play() {
const { container } = this.player.elements; const { container } = this.player.elements;
// Initialize the container. Must be done via a user action on mobile devices. if (!this.adsManagerPromise) {
this.adDisplayContainer.initialize(); return;
}
// Play the requested advertisement whenever the adsManager is ready. // Play the requested advertisement whenever the adsManager is ready.
this.adsManagerPromise.then(() => { this.adsManagerPromise.then(() => {
// Initialize the container. Must be done via a user action on mobile devices.
this.adDisplayContainer.initialize();
try { try {
if (!this.initialized) { if (!this.initialized) {