📜  getusermedia deviceid - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:32.809000             🧑  作者: Mango

代码示例1
navigator.mediaDevices.enumerateDevices()
.then(devices => {
  var camera = devices.find(device => device.kind == "videoinput");
  if (camera) {
    var constraints = { deviceId: { exact: camera.deviceId } };
    return navigator.mediaDevices.getUserMedia({ video: constraints });
  }
})
.then(stream => video.srcObject = stream)
.catch(e => console.error(e));