-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathStereoAudioRecorder.js
53 lines (41 loc) · 1.18 KB
/
StereoAudioRecorder.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ======================
// StereoAudioRecorder.js
function StereoAudioRecorder(mediaStream) {
// void start(optional long timeSlice)
// timestamp to fire "ondataavailable"
this.start = function(timeSlice) {
timeSlice = timeSlice || 1000;
mediaRecorder = new StereoAudioRecorderHelper(mediaStream, this);
mediaRecorder.record();
timeout = setInterval(function() {
mediaRecorder.requestData();
}, timeSlice);
};
this.stop = function() {
if (mediaRecorder) {
mediaRecorder.stop();
clearTimeout(timeout);
this.onstop();
}
};
this.pause = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.pause();
};
this.resume = function() {
if (!mediaRecorder) {
return;
}
mediaRecorder.resume();
};
this.ondataavailable = function() {};
this.onstop = function() {};
// Reference to "StereoAudioRecorder" object
var mediaRecorder;
var timeout;
}
if (typeof MediaStreamRecorder !== 'undefined') {
MediaStreamRecorder.StereoAudioRecorder = StereoAudioRecorder;
}