-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (33 loc) · 949 Bytes
/
index.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
"use strict";
const bindings = require("bindings")("camera-settings");
class CameraSettings {
constructor(cameraId) {
this.cameraId = cameraId;
}
async open() {
await bindings.openCameraSettings(this.cameraId);
if (global.window) {
const cameraId = this.cameraId;
this.bindClose = () => {
bindings.closeCameraSettingsSync(cameraId)
};
window.addEventListener("beforeunload", this.bindClose);
}
}
close() {
if (global.window && this.bindClose) {
window.removeEventListener("beforeunload", this.bindClose);
}
return bindings.closeCameraSettings(this.cameraId);
}
getSettings() {
return bindings.getCameraSettings(this.cameraId);
}
setSettings(settings) {
return bindings.setCameraSettings(this.cameraId, settings);
}
getResolutions() {
return bindings.getCameraResolutions(this.cameraId);
}
}
module.exports = { CameraSettings, ...bindings };