Chrome won't play WebAudio getUserMedia via WebRTC/Peer.js

后端 未结 3 1928
情书的邮戳
情书的邮戳 2020-12-10 08:41

I want to make a simple audio only stream over WebRTC, using Peer.js. I\'m running the simple PeerServer locally.

The following works perfectly fine in Firefox 30, b

3条回答
  •  臣服心动
    2020-12-10 09:14

    This still appears to be an issue even in Chrome 73.

    The solution that saved me for now is to also connect the media stream to a muted HTML audio element. This seems to make the stream work and audio starts flowing into the WebAudio nodes.

    This would look something like:

    let a = new Audio();
    a.muted = true;
    a.srcObject = stream;
    a.addEventListener('canplaythrough', () => {
        a = null;
    });
    
    let audioStream = audioContext.createMediaStreamSource(stream);
    audioStream.connect(audioContext.destination);
    

    JSFiddle: https://jsfiddle.net/jmcker/4naq5ozc/


    Original Chromium issue and workaround: https://bugs.chromium.org/p/chromium/issues/detail?id=121673#c121

    New Chromium issue: https://bugs.chromium.org/p/chromium/issues/detail?id=687574 https://bugs.chromium.org/p/chromium/issues/detail?id=933677

提交回复
热议问题