-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
25 lines (22 loc) · 855 Bytes
/
main.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
document.getElementById('playButton').addEventListener('click', function() {
let mood = document.querySelector('input[name="mood"]:checked').value;
console.log(getMusicPath(mood));
let audio = new Audio(getMusicPath(mood));
audio.play();
document.getElementById('pauseButton').addEventListener('click', function() {
if (audio) {
audio.pause();
}
})
function getMusicPath(mood) {
if (mood === 'happy') {
return 'audios/happy_song.mp3'; // Replace with the path to your happy song
} else if (mood === 'sad') {
return 'audios/sad_song.mp3'; // Replace with the path to your sad song
} else if (mood === 'hype') {
return 'audios/hype_song.mp3'
} else if (mood === 'chill') {
return 'audios/chill_song.mp3'
}
}
});