Update LocalAudioPlayer and chapters view for improved functionality #4721
+15
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief summary
This PR fixes two issues related to audio playback in the Audiobookshelf client: preventing multiple audio streams from playing simultaneously and ensuring chapter previews stop at the end of the chapter without auto-advancing.
Which issue is fixed?
Chapter Preview Doesn’t Stop at Chapter End
Multiple Audio Streams Playing Simultaneously
In-depth Description
Multiple Audio Streams Playing Simultaneously:
The issue occurs when multiple audio streams (e.g., from different chapters or previews) start playing at the same time, leading to overlapping sounds.
Solution: Added event listeners to detect when a new audio stream begins and automatically pause any currently playing audio. This ensures only one stream is active at a time.
Updated files: client/pages/audiobook/_id/chapters.vue and client/players/LocalAudioPlayer.js.
This is a common edge case for users previewing multiple chapters quickly, improving the overall user experience by preventing audio chaos without affecting core playback logic.
Chapter Preview Doesn’t Stop at Chapter End:
The problem is that when previewing a single chapter, the player auto-advances to the next chapter instead of stopping at the end.
Solution: Removed the auto-advance logic specifically for single-chapter preview mode, allowing the playback to end naturally at the chapter's conclusion.
Updated file: client/pages/audiobook/_id/chapters.vue.
This fix targets preview functionality, which is useful for users scanning books, and doesn't impact full audiobook playback.
How have you tested this?
Open an audiobook page in a local development environment (run npm run dev).
Start playing a chapter preview.
Quickly start another chapter preview.
Verify that the first audio pauses immediately when the second starts, with no overlap.
Test with multiple browsers/tabs to simulate concurrent plays.
Ensured no regression in standard full-book playback.
Screenshots