-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhd1.html
57 lines (55 loc) · 1.58 KB
/
hd1.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
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=no">
<title>HD getUserMedia</title>
<style>
html, body {
margin: 0 auto;
color: #fff;
}
video {
width: 100vw;
height: 100vh;
background: black;
}
pre {
position: absolute;
top: 24px;
left: 24px;
right: 24px;
text-shadow: 0 0 black;
}
</style>
<video id="video" autoplay muted></video>
<pre id="log"></pre>
<script>
async function getUserMedia() {
const portraitModeConstraints = {
video: {
facingMode: 'user',
width: 1920,
height: 1080,
}
};
const landscapeModeConstraints = {
video: {
facingMode: 'user',
width: 1920,
height: 1080,
}
};
const options = (screen.orientation.type.startsWith('portrait') ? portraitModeConstraints : landscapeModeConstraints);
console.log(options.video);
video.srcObject = await navigator.mediaDevices.getUserMedia(options);
video.onloadedmetadata = async event => {
await video.play();
log.textContent = JSON.stringify(options, 0, 2) + '\r\n\r\n';
log.textContent += 'Result: ' + video.videoWidth + 'x' + video.videoHeight;
log.textContent += 'Track settings: ';
var track = video.srcObject.getVideoTracks()[0];
log.textContent += track.getSettings().width + 'x' + track.getSettings().height;
log.textContent += ' facingMode = ' + track.getSettings().facingMode;
log.textContent += ' gDM = ' + navigator.mediaDevices.getDisplayMedia;
}
}
getUserMedia();
screen.orientation.addEventListener('change', getUserMedia);
</script>