收藏
回答

部分安卓机型不支持getUserMedia?

安卓手机 华为 nova4 在企业微信用getUserMedia调用摄像头 报domException错误 ,但是没有错误代码和错误消息提示 ,其他安卓机型可以

      var constraints = { audio: false,
        video: { width: this.videoWidth,
          height: this.videoHeight,
/*          transform: 'scaleX(-1)',*/
          facingMode: {exact: 'environment'}}
        //video: { facingMode: {exact: 'environment'}, width: this.videoWidth, height: this.videoHeight }
      };

      if (navigator.mediaDevices.getUserMedia) {
        navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
          // 旧的浏览器可能没有srcObject
          console.log('med_getUserMedia')
          if ('srcObject' in _this.thisVideo) {
            _this.thisVideo.srcObject = stream;
          } else {
            // 避免在新的浏览器中使用它,因为它正在被弃用。
            window.URL = window.URL || window.webkitURL || window.msURL || window.mozURL;
            _this.thisVideo.src = window.URL && window.URL.createObjectURL(stream);
          }
          _this.thisVideo.onloadedmetadata = function (e) {
            _this.thisVideo.play();
            _this.screenShot();
          };
        }).catch(err => {
          console.log('err', err);
          navigator.getUserMedia(constraints,
            function(stream) {
              console.log('getUserMedia')
              if ('srcObject' in _this.thisVideo) {
                _this.thisVideo.srcObject = stream;
              } else {
                // 避免在新的浏览器中使用它,因为它正在被弃用。
                window.URL = window.URL || window.webkitURL || window.msURL || window.mozURL;
                _this.thisVideo.src = window.URL && window.URL.createObjectURL(stream);
              }
              _this.thisVideo.onloadedmetadata = function(e) {
                _this.thisVideo.play();
              };
            },
            function(err) {
              console.log('err1', err1);
            }
          );
        });
      }
回答关注问题邀请回答
收藏

1 个回答

  • 企业微信运营专员-千夜
    企业微信运营专员-千夜
    2020-04-14

    您好,可以提供下

    Corpid:

    问题成员手机号:

    调用接口:

    出现问题时间点(具体到月日时分):

    截图:

    异常页面链接/请求url/相关可访问的url:(给报错界面的链接,没有报错的,给一个可访问链接+操作路径)

    我们看下哈

    2020-04-14
    有用
    回复
登录 后发表内容
问题标签