-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
54 lines (43 loc) · 1.44 KB
/
Copy pathtest.html
File metadata and controls
54 lines (43 loc) · 1.44 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>WebRTC :: Test :: Selenoid</title>
<script type="text/javascript" src="https://webrtchacks.github.io/adapter/adapter-latest.js"></script>
</head>
<body>
<h1>Привет мир!</h1>
<p>
<button id="startBtn" >Start</button>
</p>
<p>
<video id="localCam" autoplay muted></video>
</p>
<script type="text/javascript">
'use strict';
document.addEventListener("DOMContentLoaded", () => {
const startBtn = document.getElementById("startBtn")
const videoElement = document.getElementById("localCam");
startBtn.addEventListener("click", start)
console.debug("window.navigator", window.navigator.mediaDevices)
console.debug("navigator", navigator.mediaDevices)
window.navigator.mediaDevices.enumerateDevices()
.then((devices) => {
devices.forEach((device) => {
console.debug(`DEVICE: ${device.kind}: ${device.label} id = ${device.deviceId}`);
});
})
.catch((err) => {
console.error(`${err.name}: ${err.message}`);
});
function start() {
window.navigator.mediaDevices.getUserMedia({video:true}).then(stream => {
videoElement.srcObject=stream
}).catch(e => {
console.error("start", e)
})
}
})
</script>
</body>
</html>