WebRTC Video/Audio stream, but Audio is not playing

拈花ヽ惹草 提交于 2019-12-13 17:06:24

问题


I am working on an Electron app with React.js that sets up some peer connections through webRTC. Everything looks good with the connections and the peers receive the stream, but the video on the peers end does no play the audio. Perhaps I'm just not understanding how getUserMedia works, but I thought setting constraints true for audio and video was enough.

Relavent HTML (Peer)

<video ref="video" autoplay></video>

A few snippets of the code getting the stream

// constraints
this.constraints = {
    video: true,
    audio: true,
};

this.sdpConstraints = {
    'mandatory': {
        'OfferToReceiveAudio': this.constraints.audio,
        'OfferToReceiveVideo': this.constraints.video
    }
};

...
// getting/setting local video
setupLocalMedia(){
    navigator.mediaDevices.getUserMedia(self.constraints)
    .then(function(stream){
        self.localVideo.src = window.URL.createObjectURL(stream);
        self.stream = stream;
        window.stream = stream;
     }).catch(self.errorHandler);
}

// adding the stream to the peer
peerConnection.onaddstream = function(event){
    peerVideo.src = window.URL.createObjectURL(event.stream); 
};

Again, all the connections are working just fine, and the video is streaming as expected, but no audio. Consoling the stream shows that the audio channel is enabled. Any ideas?

来源:https://stackoverflow.com/questions/37574337/webrtc-video-audio-stream-but-audio-is-not-playing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!