Skip to content

Commit

Permalink
Merge pull request BloomBooks#323 from StephenMcConnel/BL-13905-PageS…
Browse files Browse the repository at this point in the history
…wipeDoesntKillAudio

fix: Stop audio in progress immediately when changing pages (BL-13905)
  • Loading branch information
andrew-polk authored Sep 23, 2024
2 parents f9082b5 + a16ecc7 commit fb7a144
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/narration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ export enum PlaybackMode {

export let currentPlaybackMode: PlaybackMode = PlaybackMode.NewPage;
export function setCurrentPlaybackMode(mode: PlaybackMode) {
if (
currentPlaybackMode === PlaybackMode.AudioPlaying &&
mode === PlaybackMode.NewPage
) {
const mediaPlayer = getPlayer();
if (mediaPlayer) {
// Make sure the audio stops (pauses) before we move on to the next page. (See BL-13905.)
// Make the current playing element the only one in the stack for the playEnded() method
// to process.
elementsToPlayConsecutivelyStack = [mediaPlayer];
playEnded();
}
}
currentPlaybackMode = mode;
}

Expand Down

0 comments on commit fb7a144

Please sign in to comment.