Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/sounds/shortBuzz.mp3
Binary file not shown.
Binary file added public/sounds/shortBuzz.webm
Binary file not shown.
Binary file added public/sounds/softPing.mp3
Binary file not shown.
Binary file added public/sounds/sonar.wav
Binary file not shown.
9 changes: 9 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ body {
margin-left: 5px;
}

.App header .nav-buttons select.text-select {
background-color: var(--darkBlueColor);
color: white;
border: none;
padding: 8px 10px;
border-radius: 4px;
font-weight: 500;
}

/* BUTTON */

.App button {
Expand Down
13 changes: 10 additions & 3 deletions src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ export default function Header({
</Navbar.Brand>
<div className="nav-buttons">
{!isNil(sound) ? (
<button className="text-button" onClick={() => setSound()}>
{sound ? 'Turn off sound' : 'Turn on sound'}
</button>
<select
className="text-select"
value={sound}
onChange={(e) => setSound(e.target.value)}
>
<option value="off">Sound Off</option>
<option value="default"> Buzzer </option>
<option value="chime"> Chime </option>
<option value="sonar"> Sonar </option>
</select>
) : null}
{clearAuth ? (
<button className="text-button" onClick={() => leave()}>
Expand Down
32 changes: 28 additions & 4 deletions src/components/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,47 @@ export default function Table(game) {
some(game.G.queue, (o) => o.id === game.playerID)
);
const [lastBuzz, setLastBuzz] = useState(null);
const [sound, setSound] = useState(false);
const [sound, setSound] = useState('off');
const [soundPlayed, setSoundPlayed] = useState(false);
const buzzButton = useRef(null);
const queueRef = useRef(null);

const buzzSound = new Howl({
src: [
`${process.env.PUBLIC_URL}/shortBuzz.webm`,
`${process.env.PUBLIC_URL}/shortBuzz.mp3`,
`${process.env.PUBLIC_URL}sounds/shortBuzz.mp3`,
],
volume: 0.5,
rate: 1.5,
});

const chimeSound = new Howl({
src: [`${process.env.PUBLIC_URL}sounds/softPing.mp3`],
volume: 1,
rate: 1.5,
});

const sonarSound = new Howl({
src: [`${process.env.PUBLIC_URL}sounds/sonar.wav`],
volume: 0.5,
rate: 1.5,
});

const playSound = () => {
if (sound && !soundPlayed) {
buzzSound.play();
switch (sound) {
case 'default':
buzzSound.play();
break;
case 'chime':
chimeSound.play();
break;
case 'sonar':
sonarSound.play();
break;
default:
return;
}
setSoundPlayed(true);
}
};
Expand Down Expand Up @@ -138,7 +162,7 @@ export default function Table(game) {
})
}
sound={sound}
setSound={() => setSound(!sound)}
setSound={(value) => setSound(value)}
/>
<Container>
<section>
Expand Down