From 198acdbaf5d2416780caa8b7dce49e22d0fb4235 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Fri, 25 Nov 2022 14:45:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=81=8A=E5=A4=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD-=E5=BC=80=E5=8F=91=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/src/components/chat/ChatPrivateVideo.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/im-ui/src/components/chat/ChatPrivateVideo.vue b/im-ui/src/components/chat/ChatPrivateVideo.vue index f2eb838..a67ea87 100644 --- a/im-ui/src/components/chat/ChatPrivateVideo.vue +++ b/im-ui/src/components/chat/ChatPrivateVideo.vue @@ -98,6 +98,11 @@ // 接受呼叫 this.accept(this.offer); } + + this.timerx && clearInterval(this.timerx); + this.timerx = setInterval(()=>{ + console.log(this.peerConnection.iceConnectionState); + },3000) }); }, @@ -130,9 +135,9 @@ }, setupPeerConnection(stream) { this.peerConnection = new RTCPeerConnection(this.configuration); - this.peerConnection.onaddstream = (e) => { + this.peerConnection.ontrack = (e) => { console.log("onaddstream") - this.$refs.friendVideo.srcObject = e.stream; + this.$refs.friendVideo.srcObject = e.streams[0]; }; this.peerConnection.onicecandidate = (event) => { if (event.candidate) { @@ -146,7 +151,9 @@ } } if (stream) { - this.peerConnection.addStream(stream); + stream.getTracks().forEach((track)=>{ + this.peerConnection.addTrack(track, stream); + }); } }, handleMessage(msg) {