javascript - 有没有办法在同一页面上使用反应网络摄像头,一个用于前置摄像头,另一个用于后置摄像头?
问题描述
我正在使用 react-webcam 版本 ^4.0.0。我有一个内置反应的网页,我想使用第一个选项卡拍摄客户自拍照,并使用下一个选项卡使用他的后置摄像头拍照。对于前置摄像头,我使用以下代码:-
const videoConstraints = {
facingMode: 'user'
};
<Webcam
id="Selfie"
audio={false}
style={webcamStyle}
videoConstraints={videoConstraints}
height="auto"
// eslint-disable-next-line no-return-assign
ref={webcam => (this.webcam = webcam)}
screenshotFormat="image/jpeg"
/>
我正在使用以下代码来使用后置摄像头:-
const videoConstraints = {
facingMode: 'environment'
};
<Webcam
id="panCard"
audio={false}
style={webcamStyle}
height="auto"
videoConstraints={videoConstraints}
// eslint-disable-next-line no-return-assign
ref={webcam => (this.webcam = webcam)}
screenshotFormat="image/jpeg"
/>
问题是即使我将后置摄像头设置为环境,它仍然会打开前置摄像头。我该如何解决这个问题?任何帮助或建议表示赞赏。谢谢。
解决方案
推荐阅读
- c# - 附加信息:Procedure or function insertimi has too many arguments specified (C# SQL插入过程)
- c# - Linq 对对象的查询无法通过 Xunit 测试
- jquery - JQuery 选择器 - 如何检查特定路径是否存在?
- css - 使用类重置 CSS 计数器
- c# - C# WPF,如何检测 Datagrid 中的滚动条是否到达末尾?
- java - JPA - EntityListener - @PrePersist 和 @PreUpdate 工作成功,但 @PostPersist 和 @PostUpdate 不工作
- spring-boot - 无法使用spring cloud stream kafka发送自定义标头
- javascript - 如何在多个线程中使用 java 脚本/节点上传最大数据以测量可实现的吞吐量
- java - 从 Google 云端硬盘获取共享云端硬盘列表
- chrome-devtools-protocol - 赛普拉斯无法连接到 Chrome DevTools 协议:TCPConnectWrap.afterConnect 处的 ECONNREFUSED