Skip to content

Commit 6eb8725

Browse files
author
Brad Traversy
committed
Soound board
1 parent 1266ba7 commit 6eb8725

File tree

9 files changed

+84
-0
lines changed

9 files changed

+84
-0
lines changed

sound-board/index.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link rel="stylesheet" href="style.css" />
7+
<title>Sound Board</title>
8+
</head>
9+
<body>
10+
<audio id="applause" src="sounds/applause.mp3"></audio>
11+
<audio id="boo" src="sounds/boo.mp3"></audio>
12+
<audio id="gasp" src="sounds/gasp.mp3"></audio>
13+
<audio id="tada" src="sounds/tada.mp3"></audio>
14+
<audio id="victory" src="sounds/victory.mp3"></audio>
15+
<audio id="wrong" src="sounds/wrong.mp3"></audio>
16+
17+
<div id="buttons"></div>
18+
19+
<script src="script.js"></script>
20+
</body>
21+
</html>

sound-board/script.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const sounds = ['applause', 'boo', 'gasp', 'tada', 'victory', 'wrong']
2+
3+
sounds.forEach(sound => {
4+
const btn = document.createElement('button')
5+
btn.classList.add('btn')
6+
7+
btn.innerText = sound
8+
9+
btn.addEventListener('click', () => {
10+
stopSongs()
11+
12+
document.getElementById(sound).play()
13+
})
14+
15+
document.getElementById('buttons').appendChild(btn)
16+
})
17+
18+
function stopSongs() {
19+
sounds.forEach(sound => {
20+
const song = document.getElementById(sound)
21+
22+
song.pause()
23+
song.currentTime = 0;
24+
})
25+
}

sound-board/sounds/applause.mp3

61.3 KB
Binary file not shown.

sound-board/sounds/boo.mp3

45.6 KB
Binary file not shown.

sound-board/sounds/gasp.mp3

9.91 KB
Binary file not shown.

sound-board/sounds/tada.mp3

45.3 KB
Binary file not shown.

sound-board/sounds/victory.mp3

66.5 KB
Binary file not shown.

sound-board/sounds/wrong.mp3

1.52 KB
Binary file not shown.

sound-board/style.css

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;400&display=swap');
2+
3+
* {
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
background-color: rgb(161, 100, 223);
9+
font-family: 'Poppins', sans-serif;
10+
display: flex;
11+
flex-wrap: wrap;
12+
align-items: center;
13+
justify-content: center;
14+
text-align: center;
15+
height: 100vh;
16+
overflow: hidden;
17+
margin: 0;
18+
}
19+
20+
.btn {
21+
background-color: rebeccapurple;
22+
border-radius: 5px;
23+
border: none;
24+
color: #fff;
25+
margin: 1rem;
26+
padding: 1.5rem 3rem;
27+
font-size: 1.2rem;
28+
font-family: inherit;
29+
cursor: pointer;
30+
}
31+
32+
.btn:hover {
33+
opacity: 0.9;
34+
}
35+
36+
.btn:focus {
37+
outline: none;
38+
}

0 commit comments

Comments
 (0)