Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from claustra01/add_sound
Browse files Browse the repository at this point in the history
add: sound_file&音声を追加
  • Loading branch information
claustra01 authored Aug 10, 2024
2 parents 6eead73 + 9ee97fc commit f80e349
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"ignorePaths": ["node_modules/**", "*.svg"],
"version": "0.2",
"language": "en",
"words": ["NATSUMATSURI", "yatai", "Dela", "Yuji", "Syuku", "zustand"]
"words": ["NATSUMATSURI", "yatai", "Dela", "Yuji", "Syuku", "zustand", "wadaiko"]
}
Binary file added public/sound/cork_sound.mp3
Binary file not shown.
13 changes: 12 additions & 1 deletion src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ function Home() {
}, []);

const handleClick = () => {
window.location.href = isPcScreen ? "/yatai" : "/shooter";
const audio = new Audio("/sound/wadaiko.mp3");
audio
.play()
.then(() => {
setTimeout(() => {
window.location.href = isPcScreen ? "/yatai" : "/shooter";
}, 500);
})
.catch((error) => {
console.error("オーディオの音が出なかった", error);
window.location.href = isPcScreen ? "/yatai" : "/shooter";
});
};

return (
Expand Down
11 changes: 10 additions & 1 deletion src/pages/shooter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ function Shooter() {
const [images, setImages] = useState(initialImages);

const handleClick = () => {
setImages((prevImages) => prevImages.slice(1));
const audio = new Audio("/sound/cork_sound.mp3");
audio
.play()
.then(() => {
setImages((prevImages) => prevImages.slice(1));
})
.catch((error) => {
console.error("オーディオの音が出なかった", error);
setImages((prevImages) => prevImages.slice(1));
});
};

const handleKeyUp: KeyboardEventHandler<HTMLDivElement> = (event) => {
Expand Down

0 comments on commit f80e349

Please sign in to comment.