Im trying to Embed two webcam streams on one HTML page.
I am use to a get user media script that I got from this site https://www.kirupa.com/html5/accessing_your_webcam_in_html5.htm
It works fine for one steam but when I try to make two different video streams on the same page it doesn't work.
I have tried making a div tag with a grid in it and putting one video element in each cell. This results in only one stream.
Here is my most recent try
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="stuff, to, help, search, engines, not" name="keywords">
<meta content="What this page is about." name="description">
<meta content="Display Webcam Stream" name="title">
<title>Display Webcam Stream</title>
<style>
#container {
margin: 0px auto;
width: 500px;
height: 375px;
border: 10px #333 solid;
}
#videoElement {
width: 500px;
height: 375px;
background-color: #666;
}
#container2 {
margin: 0px auto;
width: 500px;
height: 375px;
border: 10px #333 solid;
}
#videoElement2 {
width: 500px;
height: 375px;
background-color: #666;
}
</style>
</head>
<body style="">
<div id="container">
<video autoplay id="videoElement">
</video>
</div>
<div id="container2">
<video2 autoplay="true" id="videoElement2">
</video2>
</div>
<script>
var video = document.querySelector("#videoElement");
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({
video: true
}, handleVideo, videoError);
}
function handleVideo(stream) {
video.src = window.URL.createObjectURL(stream);
}
function videoError(e) { // do something
}
</script>
</body>
</html>
Can anyone help?