我使用的是https://github.com/jhuckaby/webcamjs的webcam.js,在移动设备中,默认情况下前置摄像头是打开的。我想要将默认设置更改为后置摄像头。有没有办法更换摄像设备?
发布于 2018-07-01 17:21:13
var constraints = {
video: true,
facingMode: "environment"
};发布于 2020-09-01 05:17:24
<script src="/js/webcamjs/webcam.js"></script>
<div id="my_camera" style="width:320px; height:240px;"></div>
<div id="my_result"></div>
<script language="JavaScript">
Webcam.set('constraints',{
facingMode: "environment"
});
Webcam.attach( '#my_camera' );
function take_snapshot() {
Webcam.snap( function(data_uri) {
document.getElementById('my_result').innerHTML = '<img src="'+data_uri+'"/>';
} );
}
</script>
<a href="javascript:void(take_snapshot())">Take Snapshot</a>https://stackoverflow.com/questions/42866508
复制相似问题