【问题标题】:OpenVidu WebRTC replaceTrack for camera on ios safari loses audio inputios safari 上相机的 OpenVidu WebRTC replaceTrack 丢失音频输入
【发布时间】:2022-08-03 21:20:21
【问题描述】:

我在 openvidu 论坛上没有解决这个问题。我有一个使用 openvidu 构建的用于实时流媒体的网络应用程序,一切都在除 ios 之外的所有设备上完美运行

在我的 iphone 上的 safari 中,如果我更换视频轨道以基本上将摄像头切换到后置摄像头,整个会话都会丢失音频输入。这不会发生在 android 设备或我的网络浏览器上,它只是在 iphone 上。

这是我如何切换相机:

this.OV.getDevices().then((devices)=> {

        let videoDevices = null;
        if(this.OVCurrentCamera === \'front\'){
          videoDevices = devices.filter(device => device.kind === \'videoinput\' && device.label !== \'Snap Camera\' && device.label.toLowerCase().indexOf(\'back\') !== -1);
        }else{
          videoDevices = devices.filter(device => device.kind === \'videoinput\' && device.label !== \'Snap Camera\' && device.label.toLowerCase().indexOf(\'front\') !== -1);
        }

        if(videoDevices){

        
          // get new device id
          // if we already on front the back device is the last one in the list otherwise the first
          let newDeviceId = this.OVCurrentCamera === \'front\' ?  videoDevices[videoDevices.length - 1].deviceId : videoDevices[0].deviceId;


          this.OV.getUserMedia(<any>{
           
            videoSource: newDeviceId,
           
          }).then((mediaStream) =>  {

          
            let videoTrack = mediaStream.getVideoTracks()[0];
           
            this.OVPublisher.replaceTrack(videoTrack).then(() => {
              this.OVCurrentCamera = this.OVCurrentCamera === \'front\' ? \'back\' : \'front\';
            }).catch(() => {
              this.toast.error(\'There was a problem switching cameras.\');
            })

          }).catch((error) => {
            console.log(\"USER MEDIA ERROR\",error)
          })


        }else{
          this.toast.error(\'Could Not Load Your Cameras\');
        }

      })

即使再次点击按钮返回前置摄像头,音频输入也不会返回。

    标签: ios webrtc openvidu


    【解决方案1】:

    当它是前置摄像头时,你能听到声音吗?我有同样的问题。我向 github issue 提出了一个问题,但我还没有收到答案。

    【讨论】:

      猜你喜欢
      • 2022-09-28
      • 2012-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多