Browse Source

feat: 多人音视频功能

master
xsx 2 years ago
parent
commit
8b824eead5
  1. 6
      im-ui/src/api/camera.js
  2. 2
      im-ui/src/components/rtc/RtcGroupVideo.vue

6
im-ui/src/api/camera.js

@ -9,15 +9,15 @@ ImCamera.prototype.isEnable = function() {
return !!navigator && !!navigator.mediaDevices && !!navigator.mediaDevices.getUserMedia; return !!navigator && !!navigator.mediaDevices && !!navigator.mediaDevices.getUserMedia;
} }
ImCamera.prototype.openVideo = function(isFacing) { ImCamera.prototype.openVideo = function() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if(this.stream){ if(this.stream){
this.close() this.close()
} }
let facingMode = isFacing ? "user" : "environment";
let constraints = { let constraints = {
video: { video: {
facingMode: facingMode with: window.screen.width,
height: window.screen.height
}, },
audio: { audio: {
echoCancellation: true, //音频开启回音消除 echoCancellation: true, //音频开启回音消除

2
im-ui/src/components/rtc/RtcGroupVideo.vue

@ -498,7 +498,7 @@
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.isCamera) { if (this.isCamera) {
// + // +
this.camera.openVideo(this.isFacing).then((stream) => { this.camera.openVideo().then((stream) => {
console.log("摄像头打开成功") console.log("摄像头打开成功")
this.stream = stream; this.stream = stream;
// //

Loading…
Cancel
Save