studiojs icon indicating copy to clipboard operation
studiojs copied to clipboard

Js warning in Chrome: AudioContext is not allowed to start

Open idreamin opened this issue 5 years ago • 2 comments

image

thank you very much !

idreamin avatar Mar 20 '19 08:03 idreamin

Anyone who is monitoring this, the solution to this is pretty easy, in the example there is a line like this:

const audioContext = new (window.AudioContext || window.webkitAudioContext)();

Really what you want to do is create the audioContext in your click handler, not as a const. E.g.


var audioContext = null;
$(".record").click(function() {
  if (audioContext == null) {
      audioContext =  new (window.AudioContext || window.webkitAudioContext)();
  }
  // rest of example will work now
});

cain06 avatar Sep 13 '19 20:09 cain06

@cain06 @ijsnow from line 37 in example I created new audioContext like this:

start = () => {
      this.audioContext =  new (window.AudioContext || window.webkitAudioContext)();
      this.recorder.start()
        .then(() => this.setState({isRecording: true}));
    }

but It still warning in Chrome and I can not record anything. Firefox and edge work fine

nvlong198 avatar Nov 05 '19 04:11 nvlong198