Skip to content

Commit

Permalink
Merge pull request #231 from ajinkyapandetekdi/all-1.3-feedback-change
Browse files Browse the repository at this point in the history
Issueid #231942 feat: audio delay right after completing level in pra…
  • Loading branch information
gouravmore authored Dec 17, 2024
2 parents 783b5e1 + 5a40064 commit a63217d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/all-dev-tn-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: ALL new tn dev Deployment
on:
push:
branches:
- all-1.3-tn-dev-hotfix
- all-1.3-feedback-change

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layouts.jsx/MainLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ const MainLayout = (props) => {
fontSize={{ md: "14px", xs: "10px" }}
>
{!gameOverData ? "Start Game ➜" : "Practice ➜"}
</span>
</Typography>
{/* <NextButton /> */}
</Box>
</Box>
Expand Down
27 changes: 25 additions & 2 deletions src/views/Practice/Practice.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,32 @@ const Practice = () => {
}
}, [startShowCase]);

const [audioSrc, setAudioSrc] = useState(null);

useEffect(() => {
const preloadAudio = async () => {
try {
const response = await fetch(LevelCompleteAudio);
const audioBlob = await response.blob();
const audioUrl = URL.createObjectURL(audioBlob);
setAudioSrc(audioUrl);
} catch (error) {
console.error("Error loading audio:", error);
}
};
preloadAudio();
}, []);

const callConfettiAndPlay = () => {
let audio = new Audio(LevelCompleteAudio);
audio.play();
if (audioSrc) {
// Play preloaded audio if available
const audio = new Audio(audioSrc);
audio.play();
} else {
// Fallback to LevelCompleteAudio if preloaded audio is not available
const fallbackAudio = new Audio(LevelCompleteAudio);
fallbackAudio.play();
}
callConfetti();
};

Expand Down

0 comments on commit a63217d

Please sign in to comment.