-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecorder.js
More file actions
32 lines (29 loc) · 826 Bytes
/
Copy pathrecorder.js
File metadata and controls
32 lines (29 loc) · 826 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
function Recorder(canvas, framesToRecord, framerate = 60, quality = 99, verbose = true) {
this.framesRecorded = 0;
this.recording = false;
this.saved = false;
this.canvas = canvas;
this.framesToRecord = framesToRecord;
this.capturer = new CCapture({ format: 'webm', framerate, quality, verbose });
}
Recorder.prototype.startRecording = function() {
if (!this.recording) {
this.capturer.start();
this.recording = true;
}
}
Recorder.prototype.capture = function() {
if (this.recording) {
if (this.framesRecorded <= this.framesToRecord) {
this.capturer.capture(this.canvas);
} else if (!this.saved) {
this.stopRecording();
}
}
}
Recorder.prototype.stopRecording = function () {
this.capturer.stop();
this.capturer.save();
this.saved = true;
this.recording = false;
}