1

我正在使用 HTML5 Canvas 拍照。它在我的腿上运行完美,但在电话中它集成了手机摄像头 html 代码

 <input type="file" accept="image/*;capture=camera"  capture> </div>
 <video autoplay id="vid" style="display: inline;" width="200" height="150"></video>

  <canvas id="canvas" width="640" height="480" style="border:1px solid #d3d3d3;"></canvas></div><br>

        <input type="button" value="Take Picture" onclick="snapshot()"/>

而JS是

function snapshot() {

    $('#vid').hide();
    $('#cam_button').hide();
    $('#loading').show();
    if (localMediaStream) {
        ctx.drawImage(video, 0, 0);
    }
    var strDataURI = canvas.toDataURL("image/png");

    //alert(strDataURI);

}

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia({video:true}, function (stream) {
    video.src = window.URL.createObjectURL(stream);
    localMediaStream = stream;
}, onCameraFail);
4

0 回答 0