mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +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())
|
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() {
|
private fun setFullscreen() {
|
||||||
// set status bar icon color to white
|
// set status bar icon color to white
|
||||||
windowInsetsControllerCompat.isAppearanceLightStatusBars = false
|
windowInsetsControllerCompat.isAppearanceLightStatusBars = false
|
||||||
|
|
||||||
viewModel.isFullscreen.value = true
|
viewModel.isFullscreen.value = true
|
||||||
|
|
||||||
if (mainActivity.screenOrientationPref == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT) {
|
updateFullscreenOrientation()
|
||||||
val height = streams.videoStreams.firstOrNull()?.height ?: exoPlayer.videoSize.height
|
|
||||||
val width = streams.videoStreams.firstOrNull()?.width ?: exoPlayer.videoSize.width
|
|
||||||
|
|
||||||
mainActivity.requestedOrientation = PlayerHelper.getOrientation(width, height)
|
|
||||||
}
|
|
||||||
|
|
||||||
commentsViewModel.setCommentSheetExpand(null)
|
commentsViewModel.setCommentSheetExpand(null)
|
||||||
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
playerBinding.fullscreen.setImageResource(R.drawable.ic_fullscreen_exit)
|
||||||
@ -1348,7 +1352,6 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
if (PlayerHelper.autoFullscreenEnabled) {
|
if (PlayerHelper.autoFullscreenEnabled) {
|
||||||
// enable auto rotation
|
// enable auto rotation
|
||||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
||||||
onConfigurationChanged(resources.configuration)
|
|
||||||
} else {
|
} else {
|
||||||
// go to portrait mode
|
// go to portrait mode
|
||||||
mainActivity.requestedOrientation = (requireActivity() as BaseActivity).screenOrientationPref
|
mainActivity.requestedOrientation = (requireActivity() as BaseActivity).screenOrientationPref
|
||||||
|
Loading…
Reference in New Issue
Block a user