-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcap2vid.js
39 lines (39 loc) · 1.33 KB
/
cap2vid.js
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
class capturecard2Video{
constructor(video, videoProperties){
this.video = video;
this.videoProperties = videoProperties;
this.mediaDevices = navigator.mediaDevices;
}
changeDevice(){
let constraints = {
video: {
width: {
min: this.videoProperties.width,
max: this.videoProperties.width,
},
height: {
min: this.videoProperties.height,
max: this.videoProperties.height,
},
frameRate: this.videoProperties.fps
},
audio: {
echoCancellation: false,
autoGainControl: false,
noiseSuppression: false,
}
}
if(typeof this.videoProperties.deviceId.video == "string"){
constraints.video.deviceId = this.videoProperties.deviceId.video
}
if(typeof this.videoProperties.deviceId.audio == "string"){
constraints.audio.deviceId = this.videoProperties.deviceId.audio
}
this.mediaDevices.getUserMedia(constraints).then((stream) => {
this.video.srcObject = stream;
this.video.addEventListener("loadedmetadata", () => {
this.video.play();
});
}).catch(alert);
}
}