企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
```js let audioCtx = new AudioContext(); let destination = audioCtx.createMediaStreamDestination(); var output = new MediaStream(); let micable = false; let micsource = '' navigator.mediaDevices.getUserMedia({ audio: { deviceId: '999' } }) .then(function(mic) { micable = !0; micsource = audioCtx.createMediaStreamSource(mic); }) .catch(function(error) { micable = !1; }) navigator.mediaDevices.getDisplayMedia({ audio: !0, video: !0 }).then(function(stream) { output = new MediaStream(); if (micable) { micsource.connect(destination); output.addTrack(destination.stream.getAudioTracks()[0]) } output.addTrack(stream.getVideoTracks()[0]); newRecording(output); stream.getVideoTracks()[0].onended = function() { console.log('暂停') } }) quality = 'max' function newRecording(stream) { if (quality == "max") { mediaConstraints = { mimeType: 'video/webm;codecs=vp8,opus' } } else { mediaConstraints = { mimeType: 'video/webm;codecs=vp8,opus', bitsPerSecond: 1000 } } mediaRecorder = new MediaRecorder(stream, mediaConstraints); } ```