[Error]The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.
问题:
chrome使用AudioContext时有时会遇到,用户点击了microphone button同时也允许麦克风打开,但无法获取到audio input,相同代码在edge上可以正常运行。console有以下warning:
The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.
解决:
warining中已提示,在获取到user gesture后resume or created。
navigator.mediaDevices.getUserMedia(mediaConstraints).then(stream => {
context.resume().then(() => {
//do your job with microphone input
});
});