Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issueid #231942 feat: audio delay right after completing level in pra… #231

Merged
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
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();
}, []);
ajinkyapandetekdi marked this conversation as resolved.
Show resolved Hide resolved

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();
}
ajinkyapandetekdi marked this conversation as resolved.
Show resolved Hide resolved
callConfetti();
};

Expand Down