javascript record video code example
Example 1: javascript record video in browser
<input type="file" accept="video/*" capture="camera" id="recorder"><video id="player" controls></video><script> var recorder = document.getElementById('recorder'); var player = document.getElementById('player'); recorder.addEventListener('change', function(e) { var file = e.target.files[0];
Example 2: stream recording javascript
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function enter() {
if (navigator.mozGetUserMedia) {
navigator.myGetMedia=navigator.mozGetUserMedia;
navigator.myGetMedia({video: true}, connect, error);
}
else {
alert("NO");
}
function connect(stream) {
var video = document.getElementById("my_video");
video.src = window.URL ? window.URL.createObjectURL(stream) : stream;
video.play();
var canvas = document.getElementById("c");
}
function error(e) { console.log(e); }
}
</script>
</head>
<body>
<canvas width="640" height="480" id="c"></canvas>
<input type="button" value="RECORD" onClick="enter()"/>
<input type="button" value="SAVE" />
<video id="my_video" width="640" height="480"/>
</body>
</html>
Example 3: javascript video player
<!DOCTYPE html>
<html lang="en">
<head>
<title> Easy Video Player - TutsPlus Example </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="content/global.css">
<script type="text/javascript" src="java/FWDEVPlayer.js"></script>
</head>
<body>
<!-- WE WILL ADD OUR VIDEO PLAYER HERE -->
</body>
</html>