kurento切换摄像头

2023-08-14  本文已影响0人  变异宝宝
            let constraints = {
                audio: this.voice_flag,
                video: {
                    mandatory: {
                        maxWidth: 320,
                        maxFrameRate: 15,
                        minFrameRate: 15
                    }
                }
            };
            if (this.videoSelect.length > 1) {
                this.currVideoIndex = this.currVideoIndex == 0 ? 1 : 0;
                constraints.video.optional = [
                    {
                        sourceId: this.videoSelect[this.currVideoIndex]
                    }
                ];
            }
            navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
                let localVideo =
                    this.participants[this.orgnPersonId].getVideoElement();
                let localStream = localVideo.srcObject;
                let tracks = localStream.getTracks();
                tracks.forEach((track) => {
                    track.stop();
                });
                localVideo.srcObject = stream;
                this.webRtcPeer.peerConnection
                    .getSenders()[1]
                    .replaceTrack(stream.getVideoTracks()[0]);
            });
上一篇下一篇

猜你喜欢

热点阅读