fix #19481: stop audio on previewer navigation#20258
Open
Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Open
fix #19481: stop audio on previewer navigation#20258Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Ayush-Patel-56 wants to merge 1 commit intoankidroid:mainfrom
Conversation
1cf4fc7 to
47a1d49
Compare
ujjol1234
reviewed
Feb 11, 2026
AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerViewModel.kt
Outdated
Show resolved
Hide resolved
47a1d49 to
acaa29e
Compare
| backSideOnly.emit(!backSideOnly.value) | ||
| if (!backSideOnly.value && showingAnswer.value) { | ||
| stopAudio() | ||
| showQuestion() |
Member
There was a problem hiding this comment.
It would seem sensible to me to call this before any calls to super.showQuestion or super.showAnswer, likely be overriding the method.
@BrayanDSO could I confirm this wouldn't cause an issue?
Contributor
Author
There was a problem hiding this comment.
Done!, I've refactored the audio stop logic into showQuestion/showAnswer overrides as suggested. Also added regression test.
acaa29e to
5338d5c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose / Description
Audio currently continues playing in the Previewer even when navigating to other cards or switching views. This change ensures playback stops immediately when the user navigates away or toggles the card side.
Fixes
Approach
cardMediaPlayer.stop()in onNextButtonClick, onPreviousButtonClick, and toggleBackSideOnly.How Has This Been Tested?
Expanded PreviewerViewModelTest to cover these navigation scenarios and verified they pass.
Video Proof:
https://github.com/user-attachments/assets/44304669-c881-4533-b13f-1e08682210fb
Checklist
Please, go through these checks before submitting the PR.