-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgum_multi.html
62 lines (55 loc) · 2.03 KB
/
gum_multi.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="w3.css">
<head>
<meta name=viewport content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Multiple cameras getUserMedia() demo</title>
</head>
<body>
<div class="w3-container w3-orange"> This page lists all Video Capture devices and tries to open each of them in sequence. </div>
<div id="textarea" class="w3-panel w3-pale-green w3-leftbar w3-border-green w3-card-8 w3-medium">
</div>
<br/>
</body>
<script type="text/javascript" src="dimsum.js"></script>
<script>
/* global URL */
/* global MediaStreamTrack */
var cameraIds = new Array();
function refreshSources() {
navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
var count = 0;
document.getElementById('textarea').innerHTML = "<ul class=\"w3-ul\">";
devices.forEach(function(device) {
if (device.kind != 'videoinput')
return;
cameraIds[count++] = device;
var message = "Video capture dev # "+ count + " : " + device.label + ", id: " + device.deviceId ;
console.log(message);
document.getElementById('textarea').innerHTML += "<li>" + message + "</li>\n";
});
document.getElementById('textarea').innerHTML += "</ul>";
})
.catch(function(err) {
console.log(err.name + ": " + err.message);
});
}
function capture() {
console.log("Requesting " + cameraIds.length + " video device(s)");
for (var index in cameraIds) {
var constraints = { audio : false };
constraints.video = { optional : [{ sourceId: cameraIds[index].deviceId }] };
console.log("Requesting getUserMedia: " + JSON.stringify(constraints));
navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => { createVideoTag('', 320, 240, stream); })
.catch((error) => { console.error(error); });
}
document.getElementById("btn").disabled = true;
}
createButton("btn", "Start all Video Capturer(s)", capture)
document.body.appendChild(document.createElement("br"));
refreshSources();
</script>
</html>