Browse Source

APContainer: fix AP not showing after screen off

When playing a video with "Play in background" enabled, if the screen is
switched off, the player will switch to audio, triggering a
ACTION_SHOW_PLAYER scheduled with a 100L delay that has been there since
java.
Because the screen is switched off, onPause is called, triggering a
cancellation of ACTION_SHOW_PLAYER in the LifecyleAwareScheduler,
before it can execute it.
To ensure ACTION_SHOW_PLAYER is executed when switching the screen
back on, a flag is set and checked in onResume to call
showAudioPlayerImpl
merge-requests/2174/head
Duncan McNamara 1 year ago
committed by Nicolas Pomepuy
parent
commit
32a0a741c2
  1. 7
      application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt

7
application/vlc-android/src/org/videolan/vlc/gui/AudioPlayerContainerActivity.kt

@ -105,6 +105,7 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener, Sched
private var scanProgressBar: ProgressBar? = null
private lateinit var resumeCard: Snackbar
private var preventRescan = false
private var showAudioPlayerWhenResumed = false
private var playerShown = false
val tipsDelegate: AudioTipsDelegate by lazy(LazyThreadSafetyMode.NONE) { AudioTipsDelegate(this) }
@ -511,6 +512,8 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener, Sched
else
applyMarginToProgressBar(0)
setContentBottomPadding()
if (showAudioPlayerWhenResumed)
showAudioPlayerImpl()
super.onResume()
}
@ -588,10 +591,14 @@ open class AudioPlayerContainerActivity : BaseActivity(), KeycodeListener, Sched
private fun showAudioPlayer() {
if (isFinishing) return
scheduler.scheduleAction(ACTION_SHOW_PLAYER, 100L)
// due to the 100L delay when scheduling ACTION_SHOW_PLAYER
// if switching screen off, it can be canceled, this ensures that onResume the player is shown
showAudioPlayerWhenResumed = true
}
private fun showAudioPlayerImpl() {
if (isFinishing) return
showAudioPlayerWhenResumed = false
if (!isAudioPlayerReady) initAudioPlayer()
if (audioPlayerContainer.visibility != View.VISIBLE) {
audioPlayerContainer.visibility = View.VISIBLE

Loading…
Cancel
Save