Browse Source

视频聊天功能-开发中

master
xie.bx 3 years ago
parent
commit
ecc8e23e1d
  1. 35
      im-ui/src/components/chat/ChatPrivateVideo.vue

35
im-ui/src/components/chat/ChatPrivateVideo.vue

@ -48,16 +48,17 @@
state: 'NOT_CONNECTED',
candidates: [],
configuration: {
iceServers: [{
iceServers: [
{
urls: 'stun:stun.l.google.com:19302'
},
{
urls: 'turn:www.boxim.online:3478',
urls: 'turn:8.134.92.70:3478',
credential: 'admin123',
username: 'admin'
},
{
urls: 'stun:www.boxim.online:3478'
urls: 'stun:8.134.92.70:3478'
}
]
}
@ -126,23 +127,15 @@
console.log("onaddstream")
this.$refs.friendVideo.srcObject = e.streams[0];
};
this.peerConnection.onicegatheringstatechange = (event) => {
if (this.peerConnection.iceGatheringState == 'complete') {
this.candidates.forEach((candidate) => {
this.sendCandidate(candidate);
})
}
}
this.peerConnection.onicecandidate = (event) => {
if (event.candidate) {
// if (this.state == 'CONNECTED') {
// // ,
// this.sendCandidate(event.candidate);
// } else {
// ,
this.candidates.push(event.candidate)
//}
if (this.state == 'CONNECTED') {
// ,
this.sendCandidate(event.candidate);
} else {
// ,
this.candidates.push(event.candidate)
}
}
}
if (stream) {
@ -165,9 +158,9 @@
//
this.state = 'CONNECTED';
// candidate
// this.candidates.forEach((candidate) => {
// this.sendCandidate(candidate);
// })
this.candidates.forEach((candidate) => {
this.sendCandidate(candidate);
})
}
if (msg.type == this.$enums.MESSAGE_TYPE.RTC_REJECT) {
this.$message.error("对方拒绝了您的视频请求");

Loading…
Cancel
Save