HTML5增加了對攝像和錄音的原生支持,我們可以通過一些簡單的代碼實現攝像和錄音的功能。
<!--攝像代碼--> <video id="video" width="640" height="480" autoplay="autoplay"></video> <button id="capture">拍照</button> <script> navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; if(navigator.getUserMedia){ navigator.getUserMedia({video:true},function(stream){ var video = document.querySelector("#video"); video.srcObject = stream; video.onloadedmetadata = function(e){ video.play(); }; },function(err){ console.log("攝像頭
下一篇svg css3樣式