Skip to content

Commit f97581f

Browse files
committed
add sound board
1 parent fc3b746 commit f97581f

File tree

9 files changed

+78
-0
lines changed

9 files changed

+78
-0
lines changed

09-sound board/index.html

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 src="sounds/applause.mp3" id="applause"></audio>
11+
<audio src="sounds/boo.mp3" id="boo"></audio>
12+
<audio src="sounds/gasp.mp3" id="gasp"></audio>
13+
<audio src="sounds/tada.mp3" id="tada"></audio>
14+
<audio src="sounds/victory.mp3" id="victory"></audio>
15+
<audio src="sounds/wrong.mp3" id="wrong"></audio>
16+
<div id="buttons"></div>
17+
<script src="script.js"></script>
18+
</body>
19+
</html>

09-sound board/script.js

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

09-sound board/sounds/applause.mp3

61.3 KB
Binary file not shown.

09-sound board/sounds/boo.mp3

45.6 KB
Binary file not shown.

09-sound board/sounds/gasp.mp3

9.91 KB
Binary file not shown.

09-sound board/sounds/tada.mp3

45.3 KB
Binary file not shown.

09-sound board/sounds/victory.mp3

66.5 KB
Binary file not shown.

09-sound board/sounds/wrong.mp3

1.52 KB
Binary file not shown.

09-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)