-
Notifications
You must be signed in to change notification settings - Fork 1
/
audio.js
56 lines (46 loc) · 1.53 KB
/
audio.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
54
55
56
export class Audio {
constructor() {
this.backgroundAudioElement = document.createElement('audio');
this.backgroundAudioElement.src = 'packmunn-background.mp3';
this.backgroundAudioElement.volume = 0.4;
this.munnChompElement = document.createElement('audio');
this.munnChompElement.src = 'munn-chomp.mp3';
this.munnChompElement.loop = false;
this.munnFunnElement = document.createElement('audio');
this.munnFunnElement.src = 'munn-funn.mp3';
this.munnFunnElement.loop = false;
this.backgroundAudioElement.volume = 0.5;
this.munnchElement = document.createElement('audio');
this.munnchElement.src = 'munnch.mp3';
this.munnchElement.loop = false;
this.munnchElement.volume = 0.1;
this.munnDownElement = document.createElement('audio');
this.munnDownElement.src = 'munn-down.mp3';
this.munnDownElement.loop = false;
this.munnDownElement.volume = 0.3;
}
startBackgroundMusic = () => {
this.backgroundAudioElement.play();
};
playMunnChomp = () => {
this.munnChompElement.currentTime = 0;
this.munnChompElement.play();
};
playMunnch = () => {
this.munnchElement.currentTime = 0;
this.munnchElement.play();
};
playMunnFunn = () => {
this.munnFunnElement.currentTime = 0;
this.munnFunnElement.play();
};
playMunnDown = () => {
this.munnDownElement.currentTime = 0;
this.munnDownElement.play();
};
stopAudio = () => {
this.munnchElement.src = '';
this.munnChompElement.src = '';
this.backgroundAudioElement.src = '';
};
}