forked from GitSquared/edex-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudiofx.class.js
More file actions
70 lines (66 loc) · 2.35 KB
/
Copy pathaudiofx.class.js
File metadata and controls
70 lines (66 loc) · 2.35 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class AudioManager {
constructor() {
const path = require("path");
const {Howl, Howler} = require("howler");
if (window.settings.audio === true) {
this.beep1 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep1.wav")]
});
this.beep2 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep2.wav")]
});
this.beep3 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep3.wav")],
volume: 0.6
});
this.beep4 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep4.wav")]
});
this.dismiss = new Howl({
src: [path.join(__dirname, "assets", "audio", "dismiss.wav")]
});
this.alarm = new Howl({
src: [path.join(__dirname, "assets", "audio", "alarm.wav")]
});
this.info = new Howl({
src: [path.join(__dirname, "assets", "audio", "info.wav")]
});
} else {
Howler.volume(0.0);
}
if (window.settings.audio === true && window.settings.extraAudio === true) {
this.beep5 = new Howl({
src: [path.join(__dirname, "assets", "audio", "beep5.wav")]
});
this.intro = new Howl({
src: [path.join(__dirname, "assets", "audio", "intro.wav")]
});
this.scan = new Howl({
src: [path.join(__dirname, "assets", "audio", "scan.wav")]
});
this.ping = new Howl({
src: [path.join(__dirname, "assets", "audio", "ping.wav")],
volume: 0.02
});
this.pingFailed = new Howl({
src: [path.join(__dirname, "assets", "audio", "pingFailed.wav")],
volume: 0.02
});
}
// Return a proxy to avoid errors if sounds aren't loaded
return new Proxy(this, {
get: (target, sound) => {
if (sound in target) {
return target[sound];
} else {
return {
play: () => {return true;}
}
}
}
});
}
}
module.exports = {
AudioManager
};