mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 08:20:32 +05:30
fix: navigation bar missing nav items after closing player
This commit is contained in:
parent
bbc3c4b237
commit
311329cea5
@ -143,11 +143,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
private lateinit var exoPlayer: ExoPlayer
|
private lateinit var exoPlayer: ExoPlayer
|
||||||
private lateinit var trackSelector: DefaultTrackSelector
|
private lateinit var trackSelector: DefaultTrackSelector
|
||||||
private lateinit var streams: Streams
|
private lateinit var streams: Streams
|
||||||
|
private var isPlayerTransitioning = true
|
||||||
// progress state of the motion layout transition
|
|
||||||
private var transitionStartId = 0
|
|
||||||
private var transitionEndId = 0
|
|
||||||
private var isTransitioning = true
|
|
||||||
|
|
||||||
// if null, it's been set to automatic
|
// if null, it's been set to automatic
|
||||||
private var fullscreenResolution: Int? = null
|
private var fullscreenResolution: Int? = null
|
||||||
@ -297,8 +293,8 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
// check if video has ended, next video is available and autoplay is enabled/the video is part of a played playlist.
|
// check if video has ended, next video is available and autoplay is enabled/the video is part of a played playlist.
|
||||||
if (playbackState == Player.STATE_ENDED) {
|
if (playbackState == Player.STATE_ENDED) {
|
||||||
if (!isTransitioning) {
|
if (!isPlayerTransitioning) {
|
||||||
isTransitioning = true
|
isPlayerTransitioning = true
|
||||||
if (PlayerHelper.autoPlayCountdown) {
|
if (PlayerHelper.autoPlayCountdown) {
|
||||||
showAutoPlayCountdown()
|
showAutoPlayCountdown()
|
||||||
} else {
|
} else {
|
||||||
@ -311,7 +307,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
if (playbackState == Player.STATE_READY) {
|
if (playbackState == Player.STATE_READY) {
|
||||||
// media actually playing
|
// media actually playing
|
||||||
isTransitioning = false
|
isPlayerTransitioning = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// listen for the stop button in the notification
|
// listen for the stop button in the notification
|
||||||
@ -429,6 +425,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
val mainMotionLayout = mainActivity.binding.mainMotionLayout
|
||||||
mainMotionLayout.progress = 0F
|
mainMotionLayout.progress = 0F
|
||||||
|
|
||||||
|
var transitionStartId = 0
|
||||||
|
var transitionEndId = 0
|
||||||
|
|
||||||
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
||||||
override fun onTransitionChange(
|
override fun onTransitionChange(
|
||||||
motionLayout: MotionLayout?,
|
motionLayout: MotionLayout?,
|
||||||
@ -839,15 +838,20 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
viewModel.isMiniPlayerVisible.value = false
|
viewModel.isMiniPlayerVisible.value = false
|
||||||
|
|
||||||
if (viewModel.isFullscreen.value == true) {
|
if (viewModel.isFullscreen.value == true) {
|
||||||
unsetFullscreen()
|
// wait for the mini player transition to finish
|
||||||
|
// that guarantees that the navigation bar is shown properly
|
||||||
|
// before we kill the player fragment
|
||||||
|
binding.playerMotionLayout.addTransitionListener(object : TransitionAdapter() {
|
||||||
|
override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
|
||||||
|
super.onTransitionCompleted(motionLayout, currentId)
|
||||||
|
|
||||||
// wait a short amount of time for the unset fullscreen process to properly finish
|
mainActivity.supportFragmentManager.commit {
|
||||||
// (Android animations etc...)
|
remove(this@PlayerFragment)
|
||||||
handler.postDelayed(100) {
|
}
|
||||||
mainActivity.supportFragmentManager.commit {
|
|
||||||
remove(this@PlayerFragment)
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
|
unsetFullscreen()
|
||||||
} else {
|
} else {
|
||||||
mainActivity.supportFragmentManager.commit {
|
mainActivity.supportFragmentManager.commit {
|
||||||
remove(this@PlayerFragment)
|
remove(this@PlayerFragment)
|
||||||
@ -857,7 +861,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
|
|
||||||
// save the watch position if video isn't finished and option enabled
|
// save the watch position if video isn't finished and option enabled
|
||||||
private fun saveWatchPosition() {
|
private fun saveWatchPosition() {
|
||||||
if (this::exoPlayer.isInitialized && !isTransitioning && PlayerHelper.watchPositionsVideo) {
|
if (this::exoPlayer.isInitialized && !isPlayerTransitioning && PlayerHelper.watchPositionsVideo) {
|
||||||
PlayerHelper.saveWatchPosition(exoPlayer, videoId)
|
PlayerHelper.saveWatchPosition(exoPlayer, videoId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1006,7 +1010,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
saveWatchPosition()
|
saveWatchPosition()
|
||||||
|
|
||||||
videoId = nextId ?: PlayingQueue.getNext() ?: return
|
videoId = nextId ?: PlayingQueue.getNext() ?: return
|
||||||
isTransitioning = true
|
isPlayerTransitioning = true
|
||||||
|
|
||||||
// fix: if the fragment is recreated, play the current video, and not the initial one
|
// fix: if the fragment is recreated, play the current video, and not the initial one
|
||||||
arguments?.run {
|
arguments?.run {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user