From 6b12ee1c59638c6ce67d805997fbb360df40c572 Mon Sep 17 00:00:00 2001 From: hakkisabah Date: Wed, 22 Jun 2022 00:48:48 +0300 Subject: [PATCH] permission: need to call resume() In this page : https://developer.chrome.com/blog/autoplay/#web-audio When we read the relevant page, we may need to make changes from the beginning, so we ask the user what to do before the AudioContext is called. --- .../webaudio-input/js/webaudioextended.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/content/peerconnection/webaudio-input/js/webaudioextended.js b/src/content/peerconnection/webaudio-input/js/webaudioextended.js index c201f5301..8459beacb 100644 --- a/src/content/peerconnection/webaudio-input/js/webaudioextended.js +++ b/src/content/peerconnection/webaudio-input/js/webaudioextended.js @@ -13,7 +13,17 @@ function WebAudioExtended() { window.AudioContext = window.AudioContext || window.webkitAudioContext; /* global AudioContext */ - this.context = new AudioContext(); + const self = this; + // tricky solution for suspended state + // for more information => https://developer.chrome.com/blog/autoplay/#web-audio + navigator.mediaDevices.getUserMedia({ + audio: true, + video: false, + }).then(() => { + self.context = new AudioContext(); + }).catch((err) => { + alert(`ERROR : ${err.message}`); + }); this.soundBuffer = null; }