我使用nodejs进行语音聊天。在本地我的代码正在工作。它向服务器发送语音并进入客户端。但是我将项目上传到Internet,但无法打开麦克风。它说“未捕获(承诺)domexception” 我该如何解决这个问题
function micStart() {
var constraints = {audio: true};
navigator.mediaDevices.getUserMedia(constraints).then(function (mediaStream) {
var mediaRecorder = new MediaRecorder(mediaStream);
mediaRecorder.onstart = function (e) {
this.chunks = [];
};
mediaRecorder.ondataavailable = function (e) {
this.chunks.push(e.data);
};
mediaRecorder.onstop = function (e) {
var blob = new Blob(this.chunks, {'type': 'audio/ogg; codecs=opus'});
socket.emit('radio', blob);
};
mediaRecorder.start();
setInterval(function () {
mediaRecorder.stop()
mediaRecorder.start()
}, 11000);
});
}
function mikStop() {
const socket = io();
socket.disconnect();
}