fix controls autohide not working when epsiodes list was shown

fixes #19
This commit is contained in:
Jannik 2020-12-30 20:08:19 +01:00
parent 9705a752fb
commit 489ef02a35
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
1 changed files with 12 additions and 8 deletions

View File

@ -45,6 +45,7 @@ class PlayerActivity : AppCompatActivity() {
private val rwdTime: Long = 10000.unaryMinus() private val rwdTime: Long = 10000.unaryMinus()
private val fwdTime: Long = 10000 private val fwdTime: Long = 10000
private val defaultShowTimeoutMs = 5000
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -67,9 +68,9 @@ class PlayerActivity : AppCompatActivity() {
controller = video_view.findViewById(R.id.exo_controller) controller = video_view.findViewById(R.id.exo_controller)
controller.isAnimationEnabled = false // disable controls (time-bar) animation controller.isAnimationEnabled = false // disable controls (time-bar) animation
initExoPlayer() // call in onCreate, exoplayer lives in view model
initGUI() initGUI()
initActions() initActions()
initExoPlayer() // call in onCreate, exoplayer lives in view model
} }
override fun onStart() { override fun onStart() {
@ -364,10 +365,7 @@ class PlayerActivity : AppCompatActivity() {
onViewRemovedAction = { model.player.play() } onViewRemovedAction = { model.player.play() }
} }
player_layout.addView(episodesList) player_layout.addView(episodesList)
pauseAndHideControls()
// hide player controls and pause playback
model.player.pause()
controller.hide()
} }
private fun showLanguageSettings() { private fun showLanguageSettings() {
@ -375,10 +373,16 @@ class PlayerActivity : AppCompatActivity() {
onViewRemovedAction = { model.player.play() } onViewRemovedAction = { model.player.play() }
} }
player_layout.addView(languageSettings) player_layout.addView(languageSettings)
pauseAndHideControls()
}
// hide player controls and pause playback /**
model.player.pause() * pause playback and hide controls
controller.hideImmediately() */
private fun pauseAndHideControls() {
model.player.pause() // showTimeoutMs is set to 0 when calling pause, but why
controller.showTimeoutMs = defaultShowTimeoutMs // fix showTimeoutMs set to 0
controller.hide()
} }
inner class PlayerGestureListener : GestureDetector.SimpleOnGestureListener() { inner class PlayerGestureListener : GestureDetector.SimpleOnGestureListener() {