問題:
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
});
});