mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
fix: crash on startup when auto fullscreen enabled
This commit is contained in:
parent
1bbd5c7591
commit
c49eef5faf
@ -519,18 +519,22 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
NavigationHelper.startAudioPlayer(requireContext())
|
||||
}
|
||||
|
||||
private fun updateFullscreenOrientation() {
|
||||
if (PlayerHelper.autoFullscreenEnabled || this::streams.isInitialized) return
|
||||
|
||||
val height = streams.videoStreams.firstOrNull()?.height ?: exoPlayer.videoSize.height
|
||||
val width = streams.videoStreams.firstOrNull()?.width ?: exoPlayer.videoSize.width
|
||||
|
||||
mainActivity.requestedOrientation = PlayerHelper.getOrientation(width, height)
|
||||
}
|
||||
|
||||
private fun setFullscreen() {
|
||||
// set status bar icon color to white
|
||||
windowInsetsControllerCompat.isAppearanceLightStatusBars = false
|
||||
|
||||
viewModel.isFullscreen.value = true
|
||||
|
||||
if (mainActivity.screenOrientationPref == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT) {
|
||||
val height = streams.videoStreams.firstOrNull()?.height ?: exoPlayer.videoSize.height
|
||||
val width = streams.videoStreams.firstOrNull()?.width ?: exoPlayer.videoSize.width
|
||||
|
||||
mainActivity.requestedOrientation = PlayerHelper.getOrientation(width, height)
|
||||
}
|
||||
updateFullscreenOrientation()
|
||||
|
||||
commentsViewModel.setCommentSheetExpand(null)
|
||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
||||
@ -1348,7 +1352,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
||||
if (PlayerHelper.autoFullscreenEnabled) {
|
||||
// enable auto rotation
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
||||
onConfigurationChanged(resources.configuration)
|
||||
} else {
|
||||
// go to portrait mode
|
||||
mainActivity.requestedOrientation = (requireActivity() as BaseActivity).screenOrientationPref
|
||||
|
Loading…
Reference in New Issue
Block a user