HTML5调用摄像头录制视频
- 不支持ie,ie下不支持webrtc,无法使用navigator.getUserMedia调用摄像头
<!DOCTYPE html>
<html>
<head>
<title>video recoder</title>
<script src="fileSaver.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
</head>
<style>
body{
background-color:#EFEDEF;
}
</style>
<body>
<article style="border:1px solid white;width:400px;height:400px;margin:0 auto;background-color:white;">
<section class="experiment" style="width:320px; height:240px;border:1px solid green; margin:50px auto;">
<div id="videos-container" style="width:320px; height:240px;">
</div>
</section>
<section class="experiment" style="text-align:center;border:none; margin-top:20px;">
<button id="openCamera">打开摄像头</button>
<button id="start-recording" disabled>开始录制</button>
<button id="save-recording" disabled>保存</button>
</section>
</article>
<script>
var mediaStream;
var recorderFile;
var stopRecordCallback;
var openBtn = document.getElementById("openCamera");
var startBtn = document.getElementById("start-recording");
var saveBtn = document.getElementById("save-recording");
openBtn.onclick = function() {
this.disabled = true;
startBtn.disabled=false;
openCamera();
};
startBtn.onclick = function() {
this.disabled =