From 7557e6f6ba50d51bfc42ac83f8b2d8bb50e9fe54 Mon Sep 17 00:00:00 2001
From: Kai <git@seaoflaurels.com>
Date: Sat, 7 Dec 2024 11:32:28 -0600
Subject: [PATCH] prevent going full screen before the video has loaded

---
 .../fragment/mainactivity/main/VideoDetailView.kt        | 9 ++-------
 .../futo/platformplayer/views/video/FutoVideoPlayer.kt   | 5 +++++
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt
index b28cb308..7a3c7aa2 100644
--- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt
+++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailView.kt
@@ -2379,13 +2379,8 @@ class VideoDetailView : ConstraintLayout {
     }
 
     fun isLandscapeVideo(): Boolean? {
-        var videoSourceWidth = _player.exoPlayer?.player?.videoSize?.width
-        var videoSourceHeight = _player.exoPlayer?.player?.videoSize?.height
-
-        if (videoSourceWidth == null || videoSourceHeight == null || videoSourceWidth == 0 || videoSourceHeight == 0){
-            videoSourceWidth = this.video?.video?.videoSources?.get(0)?.width
-            videoSourceHeight = this.video?.video?.videoSources?.get(0)?.height
-        }
+        val videoSourceWidth = _player.exoPlayer?.player?.videoSize?.width
+        val videoSourceHeight = _player.exoPlayer?.player?.videoSize?.height
 
         return if (videoSourceWidth == null || videoSourceHeight == null || videoSourceWidth == 0 || videoSourceHeight == 0){
             null
diff --git a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt
index 8767031e..740740fa 100644
--- a/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt
+++ b/app/src/main/java/com/futo/platformplayer/views/video/FutoVideoPlayer.kt
@@ -592,6 +592,11 @@ class FutoVideoPlayer : FutoVideoPlayerBase {
 
     @OptIn(UnstableApi::class)
     fun setFullScreen(fullScreen: Boolean) {
+        // prevent fullscreen before the video has loaded to make sure we know whether it's a vertical or horizontal video
+        if(exoPlayer?.player?.videoSize?.height ?: 0 == 0 && fullScreen){
+            return
+        }
+
         updateRotateLock()
 
         if (isFullScreen == fullScreen) {
-- 
GitLab