提交工单
咨询集成、功能及报价等问题
产品 / 插件:实时音视频 / 实时语音
平台 / 框架:Electron
更新时间:2023-03-31 10:37
这是由于 macOS Monterey(12.2.1) 及以上版本需要主动设置这些设备的权限。请在 electron 主进程代码中添加以下处理:
const {systemPreferences} = require('electron')
async function checkDeviceAccessPrivilege()
{
const cameraAccessPrivilege = systemPreferences.getMediaAccessStatus('camera');
console.log(
`checkDeviceAccessPrivilege before apply cameraAccessPrivilege: ${cameraAccessPrivilege}`
);
if (cameraAccessPrivilege !== 'granted') {
await systemPreferences.askForMediaAccess('camera');
}
const micAccessPrivilege = systemPreferences.getMediaAccessStatus('microphone');
console.log(
`checkDeviceAccessPrivilege before apply micAccessPrivilege: ${micAccessPrivilege}`
);
if (micAccessPrivilege !== 'granted') {
await systemPreferences.askForMediaAccess('microphone');
}
const screenAccessPrivilege = systemPreferences.getMediaAccessStatus('screen');
console.log(
`checkDeviceAccessPrivilege before apply screenAccessPrivilege: ${screenAccessPrivilege}`
);
}
if(process.platform == 'darwin')
{
checkDeviceAccessPrivilege()
}
联系我们
文档反馈