[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