-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio.html
More file actions
26 lines (25 loc) · 836 Bytes
/
Copy pathaudio.html
File metadata and controls
26 lines (25 loc) · 836 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>音频</title>
</head>
<body>
<video src="" id="video"></video>
<script>
// Prefer camera resolution nearest to 1280x720.
// var constraints = { audio: true, video: { width: 1280, height: 720 } };
var constraints = { audio: true, video: { width: 100, height: 100 } }
navigator.mediaDevices.getUserMedia(constraints)
.then(function(mediaStream) {
var video = document.querySelector('video');
video.srcObject = mediaStream;
console.log(mediaStream)
video.onloadedmetadata = function(e) {
video.play();
}
})
.catch(function(err) { console.log(err.name + ": " + err.message); }); // always check for errors at the end.
</script>
</body>
</html>