-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathclient.js
More file actions
45 lines (33 loc) · 932 Bytes
/
Copy pathclient.js
File metadata and controls
45 lines (33 loc) · 932 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict'
var videoplay = document.querySelector('video#player');
function gotMediaStream(stream){
var videoTrack = stream.getVideoTracks()[0];
window.stream = stream;
videoplay.srcObject = stream;
}
function handleError(err){
console.log('getUserMedia error:', err);
}
function start() {
if(!navigator.mediaDevices ||
!navigator.mediaDevices.getUserMedia){
console.log('getUserMedia is not supported!');
return;
}else{
var constraints = {
video : {
width: 640,
height: 480,
frameRate:15,
facingMode: 'environment'
//,
//deviceId : deviceId ? {exact:deviceId} : undefined
},
audio : false
}
navigator.mediaDevices.getUserMedia(constraints)
.then(gotMediaStream)
.catch(handleError);
}
}
start();