辉煌仪奇
2021-08-19 11:05
采纳率: 49.1%
浏览 152

360浏览器打开摄像头失败

vue 项目 360浏览器 内核 webkit 打开浏览器失败,所有获取摄像头打开方式均为undefined,其中 navigator.mediaDevices.getUserMedia报错getUserMedia为undefined
打开摄像头函数如下

    //打开相机动作
    opencamera: function () {
      this.videoboxfather = !this.videoboxfather
      if (this.videoboxfather) {
        this.video = document.getElementById('localuser');

        let mediaDevices, getUserMedia, webkitGetUserMedia, mozGetUserMedia;

        try {
          mediaDevices = navigator.mediaDevices.getUserMedia
        } catch (e) {
          console.log(e)
          mediaDevices = undefined
        }
        try {
          getUserMedia = navigator.getUserMedia
        } catch (e) {
          console.log(e)
          getUserMedia = undefined
        }
        try {
          webkitGetUserMedia = navigator.webkitGetUserMedia
        } catch (e) {
          console.log(e)
          webkitGetUserMedia = undefined
        }
        try {
          mozGetUserMedia = navigator.mozGetUserMedia
        } catch (e) {
          console.log(e)
          mozGetUserMedia = undefined
        }
        console.log(mediaDevices, getUserMedia ,webkitGetUserMedia, mozGetUserMedia)
        if (mediaDevices || getUserMedia || webkitGetUserMedia || mozGetUserMedia
        ) {
          this.getUserMedia({
            audio: true,
            video: {width: 480, height: 320}
          }, this.opencamerasuccess, this.opencameraerror);
        } else {
          alert('不支持访问用户媒体');
        }
      }
    },

1条回答 默认 最新

相关推荐 更多相似问题