From 344a211d72865238533f7c2a3800e42f982f2910 Mon Sep 17 00:00:00 2001 From: Jeena Date: Mon, 12 Oct 2026 02:48:11 +0000 Subject: [PATCH] player: Fix vertical videos stretched to full screen On the HiMedia/Amlogic TV the video renders through the vendor video plane, which scales the decoded stream to the whole panel and ignores the letterbox geometry AspectRatioFrameLayout lays out for the SurfaceView. Portrait videos therefore filled the screen instead of being letterboxed; on emulators the same code was correct. Render the video in a TextureView instead: it lives in the normal view tree, so the aspect ratio is honored on every device. Verified on the HiMedia box (vertical short letterboxed, landscape fills the screen as before) and on the emulator. Closes #1 --- .../net/jeena/jtubetv/ui/screens/PlayerScreen.kt | 10 +++++++++- app/src/main/res/layout/player_video_view.xml | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/layout/player_video_view.xml diff --git a/app/src/main/java/net/jeena/jtubetv/ui/screens/PlayerScreen.kt b/app/src/main/java/net/jeena/jtubetv/ui/screens/PlayerScreen.kt index 6c21ee1..64e1d61 100644 --- a/app/src/main/java/net/jeena/jtubetv/ui/screens/PlayerScreen.kt +++ b/app/src/main/java/net/jeena/jtubetv/ui/screens/PlayerScreen.kt @@ -4,9 +4,11 @@ import android.net.Uri import android.os.Handler import android.os.Looper import android.view.KeyEvent +import android.view.LayoutInflater import android.view.ViewGroup import android.widget.Toast import androidx.activity.compose.BackHandler +import androidx.media3.ui.AspectRatioFrameLayout import androidx.compose.foundation.background import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.Box @@ -58,6 +60,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.launch import net.jeena.jtubetv.AppGraph +import net.jeena.jtubetv.R import net.jeena.jtubetv.data.PeerTubeRepository import net.jeena.jtubetv.data.api.VideoDetailDto import net.jeena.jtubetv.data.auth.TokenStore @@ -366,8 +369,13 @@ private fun PlayerSurface( ) { AndroidView( factory = { ctx -> - PlayerView(ctx).apply { + // TextureView surface (layout file): SurfaceView goes through the + // vendor video plane on Amlogic boxes and gets stretched full + // screen regardless of the letterbox geometry (issue #1). + (LayoutInflater.from(ctx) + .inflate(R.layout.player_video_view, null) as PlayerView).apply { useController = true + resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT this.player = player isFocusable = false descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS diff --git a/app/src/main/res/layout/player_video_view.xml b/app/src/main/res/layout/player_video_view.xml new file mode 100644 index 0000000..4c603b2 --- /dev/null +++ b/app/src/main/res/layout/player_video_view.xml @@ -0,0 +1,13 @@ + + + \ No newline at end of file