@@ -73,7 +73,6 @@ import com.github.libretube.extensions.updateIfChanged
7373import com.github.libretube.helpers.BackgroundHelper
7474import com.github.libretube.helpers.DownloadHelper
7575import com.github.libretube.helpers.ImageHelper
76- import com.github.libretube.helpers.NavBarHelper
7776import com.github.libretube.helpers.NavigationHelper
7877import com.github.libretube.helpers.PlayerHelper
7978import com.github.libretube.helpers.PlayerHelper.getCurrentSegment
@@ -115,7 +114,6 @@ import kotlinx.coroutines.launch
115114import kotlinx.coroutines.runBlocking
116115import kotlinx.coroutines.withContext
117116import kotlin.io.path.exists
118- import kotlin.math.abs
119117import kotlin.math.absoluteValue
120118
121119
@@ -142,15 +140,6 @@ class PlayerFragment : Fragment(R.layout.fragment_player), CustomPlayerCallback
142140
143141 // data and objects stored for the player
144142 private lateinit var streams: Streams
145- private val isShort: Boolean
146- get() {
147- if (PlayingQueue .getCurrent()?.isShort == true ) return true
148- if (! ::playerController.isInitialized) return false
149-
150- val currentVideoFormat = PlayerHelper .getCurrentVideoFormat(playerController)
151- ? : return false
152- return currentVideoFormat.height > currentVideoFormat.width
153- }
154143
155144 private val handler = Handler (Looper .getMainLooper())
156145
@@ -259,7 +248,6 @@ class PlayerFragment : Fragment(R.layout.fragment_player), CustomPlayerCallback
259248 }
260249 }
261250
262- var fullscreenOnShortsAlreadyDone = false
263251 override fun onPlaybackStateChanged (playbackState : Int ) {
264252 // set the playback speed to one if having reached the end of a livestream
265253 if (playbackState == Player .STATE_BUFFERING && binding.player.isLive &&
@@ -302,15 +290,6 @@ class PlayerFragment : Fragment(R.layout.fragment_player), CustomPlayerCallback
302290 bufferingTimeoutTask?.let { handler.removeCallbacks(it) }
303291 }
304292
305- if (playbackState == Player .STATE_READY && binding.playerMotionLayout.progress == 0f ) {
306- if (PlayerHelper .autoFullscreenShortsEnabled && isShort && ! fullscreenOnShortsAlreadyDone) {
307- setFullscreen()
308- fullscreenOnShortsAlreadyDone = true
309- }
310- }
311-
312- if (playbackState == Player .STATE_ENDED ) fullscreenOnShortsAlreadyDone = false
313-
314293 super .onPlaybackStateChanged(playbackState)
315294 }
316295
@@ -835,12 +814,7 @@ class PlayerFragment : Fragment(R.layout.fragment_player), CustomPlayerCallback
835814 private fun updateFullscreenOrientation () {
836815 if (PlayerHelper .autoFullscreenEnabled || ! this ::streams.isInitialized) return
837816
838- val height = streams.videoStreams.firstOrNull()?.height
839- ? : playerController.videoSize.height
840- val width =
841- streams.videoStreams.firstOrNull()?.width ? : playerController.videoSize.width
842-
843- baseActivity.requestedOrientation = PlayerHelper .getOrientation(width, height)
817+ baseActivity.requestedOrientation = PlayerHelper .getFullscreenOrientation(streams.isShort)
844818 }
845819
846820 private fun setFullscreen () {
@@ -1221,6 +1195,10 @@ class PlayerFragment : Fragment(R.layout.fragment_player), CustomPlayerCallback
12211195 seekBarPreviewListener = listener
12221196 playerControlsBinding.exoProgress.addSeekBarListener(listener)
12231197 }
1198+
1199+ if (binding.playerMotionLayout.progress == 0f && PlayerHelper .autoFullscreenShortsEnabled && streams.isShort) {
1200+ setFullscreen()
1201+ }
12241202 }
12251203
12261204 private suspend fun showRelatedStreams () {
@@ -1472,6 +1450,6 @@ class PlayerFragment : Fragment(R.layout.fragment_player), CustomPlayerCallback
14721450 }
14731451
14741452 override fun isVideoShort (): Boolean {
1475- return isShort
1453+ return streams. isShort
14761454 }
14771455}
0 commit comments