-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #1801: Audio player running after closing #4629
Fix #1801: Audio player running after closing #4629
Conversation
… complete pending requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @KevinGitonga. I can see this conceptually working (though per the videos it seems like it does functionally work), but I think some clarity is needed into why this particular approach works since it doesn't seem to exactly be "throttle control" for pausing per my comment.
Once we finalize the solution, I think you can go ahead with writing tests. That being said, until then you should consider marking this PR as 'Draft' since it isn't technically complete yet (and thus not ready for a full review).
app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
…nterfaces with viewModel to perform pause.
app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt
Show resolved
Hide resolved
Hi @KevinGitonga, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @KevinGitonga, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Hi @BenHenning yet to assert this in tests as it seems complex on grounds that the AudioPlayer is restarted when the user clicks on continue button to proceed to the next lesson in the Exploration, Also not able to find a suitable way to invoke ShadowMediaPlayer for this context. The cause of Audio Playing after the user clicks the pause button while playing on a given exploration might be caused by the below issue [1]. [1]. After observing my logs data the audio player continues to play since the audio player is not in a “prepared” state. This state is checked as noted here before actually performing a pause through the audioPlayerController in AudioViewModel here. The pause will be skipped as the player is not in a “prepared” state hence why audio will continue to play once the state changes to prepared here which is the expected behavior. This is despite the player ui fragment being hidden. The solution which works for this issue is to insert an if statement to check if a previous pause request exists as the state changes inside of this observer directly and if at the moment we have a pending request which was not executed when pauseAudio was initially invoked here. This will work if only the state is “prepared” and we have a “pending” request to pause the audio player. Kindly PTAL and advice your thoughts on this. |
Thanks for the write-up @KevinGitonga. As discussed during the meeting earlier, I think the next steps here are carefully documenting the solution & why the code works/shouldn't change if we can't actually verify this in a test. |
Thanks @BenHenning After observing my logs data the audio player continues to play since the audio player is not in a “prepared” state. This state is checked as noted here before actually performing a pause through the audioPlayerController in AudioViewModel here. The pause will be skipped as the player is not in a “prepared” state hence why audio will continue to play once the state changes to prepared here which is the expected behavior. This is despite the player view fragment being hidden. The solution which works for this issue is to insert an if statement to check if a previous pause request exists as the state changes inside of this observer directly and if at the moment we have a pending request which was not executed when pauseAudio was initially invoked here. This will work if only the state is “prepared” and we have a “pending” request to pause the audio player. The main reasons why this fix cannot be checked through tests in platforms available is because of system constraint's in testing audio. I could also not come up with a suitable way to test this after researching how to undertake this. For this scenario we would require to listen the state of audio or check the state of the player buttons which would not be applicable since the audio player view itself has already been hidden from the UI as part of the pause process. I have added comments and links to this comments and the issue itself in the code to assist other developers understand the reasons for the checks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @KevinGitonga! Left one follow-up comment, otherwise the PR LGTM. PTAL.
app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @KevinGitonga. I think you missed responding to the comment thread, but otherwise the PR LGTM.
app/src/main/java/org/oppia/android/app/player/audio/AudioFragmentPresenter.kt
Outdated
Show resolved
Hide resolved
Unassigning @BenHenning since they have already approved the PR. |
## Explanation Fix oppia#1801 This fix adds check in the implemented playStatusLiveData to complete audioPause request if any is pending while the playerStatus keeps changing. When user clicks on pause audio icon and the UI disappears there is a delay in audio actually pausing. Adding a check in playStatusLiveData completes pause pending request fast enough to prevent it from playing. ## Essential Checklist <!-- Please tick the relevant boxes by putting an "x" in them. --> - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [ ] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only <!-- Delete these section if this PR does not include UI-related changes. --> If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-(A11y)-Guide)) - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing ## Before changes demo https://user-images.githubusercontent.com/20886444/192735111-6baf46f8-3531-49f8-83d6-98277dc74c6d.mp4 ## After changes demo https://user-images.githubusercontent.com/20886444/192735968-13b7e2b5-e296-4978-9194-4df5b807897b.mp4 --------- Co-authored-by: Ben Henning <[email protected]>
Explanation
Fix #1801
This fix adds check in the implemented playStatusLiveData to complete audioPause request if any is pending while the playerStatus keeps changing. When user clicks on pause audio icon and the UI disappears there is a delay in audio actually pausing. Adding a check in playStatusLiveData completes pause pending request fast enough to prevent it from playing.
Essential Checklist
For UI-specific PRs only
If your PR includes UI-related changes, then:
Before changes demo
20220928_111629.mp4
After changes demo
20220928_112012.mp4