企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 配置参数 ``` var constraints = { video: { width: 640, height: 480, frameRate: 15,//30, // 帧率 // facingMode: "enviroment" // 摄像头 deviceId: deviceId ? deviceId : undefined // 视频设备id // 设置之后可以在手机上切换摄像头 前置后置切换 }, audio: { noiseSuppression: true, //降噪 echoCancellation: true // 回音消除 } } ``` ## 指定设备 > [参考](https://webrtc.github.io/samples/src/content/devices/input-output/) 通过 deviceid 获取流 ``` // 查询媒体 navigator.mediaDevices.enumerateDevices() .then((devices) => { devices.forEach((device) => { console.log(`${device.kind}: ${device.label} id = ${device.deviceId}`); }); }) .catch((err) => { console.error(`${err.name}: ${err.message}`); }); // 指定流 const constraints = { audio: {deviceId: audioSource ? {exact: audioSource} : undefined}, video: {deviceId: videoSource ? {exact: videoSource} : undefined} }; navigator.mediaDevices.getUserMedia(constraints).then(gotStream).then(gotDevices).catch(handleError); ```