Skip to content
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

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AudioFragmentPresenter @Inject constructor(
private val viewModel by lazy {
getAudioViewModel()
}
private var isPauseAudioRequestPending = false

/** Sets up SeekBar listener, ViewModel, and gets VoiceoverMappings or restores saved state */
fun handleCreateView(
Expand Down Expand Up @@ -101,6 +102,9 @@ class AudioFragmentPresenter @Inject constructor(
Observer {
prepared = it != UiAudioPlayStatus.LOADING && it != UiAudioPlayStatus.FAILED
binding.audioProgressSeekBar.isEnabled = prepared
if (prepared && isPauseAudioRequestPending) {
pauseAudio()
}
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
}
)

Expand Down Expand Up @@ -198,8 +202,10 @@ class AudioFragmentPresenter @Inject constructor(
viewModel.loadFeedbackAudio(contentId, allowAutoPlay)

fun pauseAudio() {
if (prepared)
if (prepared && isPauseAudioRequestPending) {
viewModel.pauseAudio()
isPauseAudioRequestPending = false
}
}

fun handleEnableAudio(saveUserChoice: Boolean) {
Expand Down Expand Up @@ -266,6 +272,7 @@ class AudioFragmentPresenter @Inject constructor(
}

private fun hideAudioFragment() {
isPauseAudioRequestPending = true
BenHenning marked this conversation as resolved.
Show resolved Hide resolved
(activity as AudioButtonListener).showAudioStreamingOff()
(fragment as AudioUiManager).pauseAudio()
val animation = AnimationUtils.loadAnimation(context, R.anim.slide_up_audio)
Expand Down