[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
      });
    });


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM