I want to write a javascript application,which have two Pages. On Page A user can click on a button and then the webcam start's streaming now I want to view that video in Page B instead of Page A.
Page B should display only the streaming video that page A has. Page B doesn't need to access webcam itself. Below is the code.
<html>
<head> </head>
<title> Webcam </title>
<body>
<center>
<div class="topnav">
<a href="index.html">Page A</a>
<a href="stream.html" >Page B</a>
</div>
<video id="video"></video><br><br>
<button onClick="capture();"> Start </button>
</center>
<script type="text/javascript">
var video = document.getElementById('video');
function capture(){
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia ||
navigator.oGetUserMedia || navigator.msGetUserMedia;
if(navigator.getUserMedia){
navigator.getUserMedia({video:true},streamWebCam,throwError);
}
function streamWebCam(stream){
video.src = window.URL.createObjectURL(stream);
alert('Video Started');
video.play();
}
function throwError(e){
alert(e.name);
}
}
</script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire