-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsounds.js
45 lines (39 loc) · 1.05 KB
/
sounds.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
export default function () {
const kitchenTimerAudio = new Audio(
'https://github.com/maykbrito/automatic-video-creator/blob/master/audios/kichen-timer.mp3?raw=true'
)
const buttonPressAudio = new Audio(
'https://github.com/maykbrito/automatic-video-creator/blob/master/audios/button-press.wav?raw=true'
)
const forestAudio = new Audio('../audio/forest.wav')
const coffeeAudio = new Audio('../audio/coffee.wav')
const rainAudio = new Audio('../audio/rain.wav')
const fireAudio = new Audio('../audio/fire.wav')
buttonPressAudio.volume = 0.35
kitchenTimerAudio.volume = 0.35
function pressButton(button) {
button.play()
}
function timeEnd() {
pressButton(kitchenTimerAudio)
}
function playAudio(sound, card) {
sound.loop = true
let isActive = card.classList.contains('active')
isActive === false ? sound.pause() : sound.play()
}
function adjustVolume(sound, volume) {
sound.volume = volume
}
return {
pressButton,
timeEnd,
playAudio,
adjustVolume,
forestAudio,
coffeeAudio,
rainAudio,
fireAudio,
buttonPressAudio
}
}