From 511cceb9d96f64fff5ab45e294a5104570877cee Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 20 Aug 2019 22:58:37 +0300 Subject: [PATCH] fix(menu) autoplay on download in firefox --- client/modules/menu.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/modules/menu.js b/client/modules/menu.js index ff9b405c..ec1d136b 100644 --- a/client/modules/menu.js +++ b/client/modules/menu.js @@ -295,6 +295,8 @@ function download(type) { src, }); + mute(element); + const {body} = document; const removeChild = body.removeChild.bind(body, element); @@ -305,6 +307,21 @@ function download(type) { } } +// prevent firefox from auto play +function mute(element) { + element.contentWindow.addEventListener('load', () => { + const video = element.contentWindow + .document + .body + .querySelector('audio, video'); + + if (!video) + return; + + video.pause(); + }); +} + function getCurrentPosition() { const current = Info.element; const rect = current.getBoundingClientRect();