From a16ecc7986337da4d27ff2271462bf22dc401d29 Mon Sep 17 00:00:00 2001 From: Steve McConnel Date: Mon, 23 Sep 2024 11:18:42 -0600 Subject: [PATCH] fix: Stop audio in progress immediately when changing pages (BL-13905) --- src/narration.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/narration.ts b/src/narration.ts index b2a5f7ad..e69d9fcc 100644 --- a/src/narration.ts +++ b/src/narration.ts @@ -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; }