navigator.mediaDevices
.getUserMedia(constrains)
.then(success)
.catch(error)
const constraints = {
video: {
width: { min: 1280, ideal: 2560, max: 3840 },
height: { min: 720, ideal: 1440, max: 2160 },
frameRate: { min: 30, ideal: 60, max: 120 },
facingMode: 'environment', // 强制后置摄像头
}
}
小程序内嵌h5使用navigator?.mediaDevices?.getUserMedia获取摄像头,苹果手机新版本黑屏,有大佬遇到过吗