小游戏支持使用navigator调用摄像头吗?仿AR
发布于 6 年前 作者 lingang 5111 次浏览 来自 问答

在小游戏中想要调用摄像头使用

navigator.mediaDevices.enumerateDevices()

.then(gotDevices)

.then(getStream).catch(handleError);

function gotDevices(deviceInfos) {

for (var i = 0; i !== deviceInfos.length; ++i) {

var deviceInfo = deviceInfos[i];

var optionvalue = document.createElement(‘option’);

optionvalue = deviceInfo.deviceId;

if (deviceInfo.kind === ‘videoinput’) { //摄像头

videoSelect.setAttribute(‘deviceid’, optionvalue);

} else {

// console.log('Found one other kind of source/device: ', deviceInfo);

}

}

}

获取不到设备的相关信息怎么处理

1 回复

你好,这个不支持

回到顶部