forked from meldron/node-alsa-capture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (27 loc) · 737 Bytes
/
index.js
File metadata and controls
31 lines (27 loc) · 737 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
const EventEmitter = require("eventemitter3");
const Capture = require("./build/Release/capture");
class AlsaCapture extends EventEmitter {
constructor(opts) {
super();
this.capture = new Capture.StreamingWorker(
((event, value, binary) => {
if (binary) {
this.emit(event, binary);
} else {
this.emit(event, value);
}
}),
(() => {
this.emit("close");
}),
((error) => {
this.emit("error", error);
}),
opts
);
}
close() {
this.capture.closeInput();
}
}
module.exports = AlsaCapture;