From 4eaa1a72b536f61587a4b4167dda417364c3ef65 Mon Sep 17 00:00:00 2001 From: Danielh112 Date: Fri, 14 Aug 2020 10:29:46 +0100 Subject: [PATCH] Fix for Slow loading videos not autoplaying --- src/js/plyr.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/js/plyr.js b/src/js/plyr.js index e924ac78..94bd819c 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -308,7 +308,7 @@ class Plyr { // Autoplay if required if (this.isHTML5 && this.config.autoplay) { - setTimeout(() => silencePromise(this.play()), 10); + this.on('canplay', () => silencePromise(this.play())); } // Seek time will be recorded (in listeners.js) so we can prevent hiding controls for a few seconds after seek @@ -1054,7 +1054,12 @@ class Plyr { const hiding = toggleClass(this.elements.container, this.config.classNames.hideControls, force); // Close menu - if (hiding && is.array(this.config.controls) && this.config.controls.includes('settings') && !is.empty(this.config.settings)) { + if ( + hiding && + is.array(this.config.controls) && + this.config.controls.includes('settings') && + !is.empty(this.config.settings) + ) { controls.toggleMenu.call(this, false); }