Skip to content

Commit

Permalink
Merge pull request #55 from hicsail/fix/audio-skip
Browse files Browse the repository at this point in the history
Fix audio skip forwards button function
  • Loading branch information
kchenturtles authored Aug 21, 2024
2 parents 7bf1e32 + 891cf57 commit cf0170c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/components/CardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,15 @@ const CardModal: React.FC<Props> = ({
style={{ color: "black" }}
onClick={() => {
if (currentIndex > 0) {
if (currentIndex < audios.length) {
const currentAudio = audios[currentIndex];
if (currentAudio) {
currentAudio.pause();
currentAudio.currentTime = 0; // Reset audio to start
}
}
setCurrentIndex(currentIndex - 1);
setIsPlaying(true);
}
}}
>
Expand All @@ -355,7 +363,15 @@ const CardModal: React.FC<Props> = ({
style={{ color: "black" }}
onClick={() => {
if (currentIndex < sentenceRefs.current.length - 1) {
if (currentIndex < audios.length) {
const currentAudio = audios[currentIndex];
if (currentAudio) {
currentAudio.pause();
currentAudio.currentTime = 0; // Reset audio to start
}
}
setCurrentIndex(currentIndex + 1);
setIsPlaying(true);
}
}}
>
Expand Down

0 comments on commit cf0170c

Please sign in to comment.