5db9a3f32a
Updated a few demos to work on Firefox. R=dutton@google.com Review URL: https://webrtc-codereview.appspot.com/1581006 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5464 4adac7df-926f-26a2-2b94-8c16560cd09d
51 lines
1.0 KiB
HTML
51 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>getUserMedia Demo 2</title>
|
|
<!-- Load the polyfill to switch-hit between Chrome and Firefox -->
|
|
<script src="../../base/adapter.js"></script>
|
|
<style>
|
|
video {
|
|
border:5px solid black;
|
|
width:480px;
|
|
height:360px;
|
|
}
|
|
canvas {
|
|
border:5px solid black;
|
|
width:480px;
|
|
height:360px;
|
|
}
|
|
button {
|
|
font: 18px sans-serif;
|
|
padding: 8px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<video id="vid" autoplay="true"></video>
|
|
<canvas id="cvs"></canvas>
|
|
<br>
|
|
<button id="btn1" onclick="start()">Start</button>
|
|
<button id="btn2" onclick="snap()">Snapshot</button>
|
|
<script>
|
|
video = document.getElementById("vid");
|
|
canvas = document.getElementById("cvs");
|
|
canvas.width = 480;
|
|
canvas.height = 360;
|
|
btn2.disabled = true;
|
|
function start() {
|
|
navigator.getUserMedia({video:true}, gotStream, function() {});
|
|
btn1.disabled = true;
|
|
}
|
|
function gotStream(stream) {
|
|
attachMediaStream(video, stream);
|
|
btn2.disabled = false
|
|
}
|
|
function snap() {
|
|
canvas.getContext("2d").drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|