-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Video is cut on the edge when using Compose and uses RESIZE_MODE_ZOOM - Only Android 14 #1123
Comments
In the bugreport there is an
|
According to: media/libraries/ui/src/main/java/androidx/media3/ui/AspectRatioFrameLayout.java Lines 174 to 209 in d13a0f4
And you are right, AspectRatioFrameLayout will be bigger than PlayerView, but that's ok, because the parent will end up cropping it.
Given that the screen width is only 392dp, Android tries to position the ARFL in the centre by:
My guess is that since the stretch in Android14 is bigger, there is some delay in stretching the view? I managed to reproduce your issue, but it disappears so quickly that I cannot catch the setup in the state where the width: Resizing.mov |
Thank you very much for testing it. Have you tried the uploaded Demo Project? I am using
use_controller_false.mp4
use_controller_true.mp4 |
I'm +1 - ing this issue. I ran into this earlier this week where my video would be rendered stretched and it seems to be related. Setting 'controllerAutoShow' to true triggers a re-layout of the PlayerView, thus correcting its size. Below is a sample project which is essentially this box in an activity;
|
I'm also seeing this issue on my app. Also, please note that it happens a lot on Android 14 devices, but ALSO on Android 13 and lower, when playing HLS and when a track change occurs (linked to available bandwidth). |
I'm also facing this issue. |
This one might work |
@jdelga Could you try setting |
As you can see in the Demo project, the issue happens when using a full Compose implementation. The only |
My current solution is use fillXXX in the specific case. For example. if i want RESIZE_MODE_FIXED_WIDTH i use the container with fillMaxWith() and not fillMaxSize(). that works to solve my use cases. |
I used this solution in my compose project, it works perfectly. First, i created a new layout called <?xml version="1.0" encoding="utf-8"?>
<androidx.media3.ui.PlayerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/custom_video_player"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:surface_type="texture_view"
app:use_controller="false" /> As mentioned by @promanowicz, the property Then i inflated that file in compose: @Composable
fun VideoComponent() {
val context = LocalContext.current
val exoplayer = remember {
ExoPlayer.Builder(context)
.setTrackSelector(trackSelector)
.build()
.apply {
setMediaItem(MediaItem.fromUri("your_video_url"l))
prepare()
play()
playWhenReady = true
}
}
var exoPlayerView = remember {
val view = View.inflate(context, R.layout.video_player, null)
val playerView = view.findViewById<PlayerView>(R.id.custom_video_player)
playerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
playerView.player = exoplayer
playerView
}
AndroidView(
modifier = Modifier.fillMaxSize()
factory = { exoPlayerView }
)
} |
Version
Media3 1.2.1
More version details
Reproduced also in latest version of Exoplayer, and Media3 1.3.0-beta01
Devices that reproduce the issue
Any device or emulator running Android 14
Devices that do not reproduce the issue
Any device or emulator running Android 13 or lower
Reproducible in the demo app?
No
Reproduction steps
Reproduced in Demo Project: Demo project
Just open the app and check the video dimensions
The bug happens in the following conditions:
AndroidView
in ComposefillMaxSize()
modifierRESIZE_MODE_ZOOM
(It also happens in RESIZE_MODE_FIXED_HEIGHT, RESIZE_MODE_FIXED_WIDTH and RESIZE_MODE_FIT, but does not happen with RESIZE_MODE_FILL)
Expected result
The video is not cut on the edge.
Actual result
The video is cut:
You can check closer to the status bar to identify the issue
Just change the
resizeMode
in the demo app to check the issue with other resize modes: https://github.com/jdelga/Media3ComposeDemo/blob/main/app/src/main/java/com/javierdelgado/media3composedemo/VideoScreen.kt#L21Media
Not applicable, but a media item is already added to the demo project
Bug Report
adb bugreport
to android-media-github@google.com after filing this issue.Comments
It would be very useful to add full support to
resizeMode
(currently as UnstableApi) and add a proper Compose player.The text was updated successfully, but these errors were encountered: