Exo Player Video is cutoff when user switches to Full Screen Portrait Mode
Version
Media3 1.3.0
More version details
No response
Devices that reproduce the issue
Pixel 6A running Android 14 Pixel 8 Pro running Android 14, but only some users.
Devices that do not reproduce the issue
Pixel 3 running Android Pie New Pixel 8 Pro Emulators for Pixel 6A and Pixel 8 Pro
Reproducible in the demo app?
Yes
Reproduction steps
Not tested. The issue has been reproduced in a simplified app created for testing, which indicates the problem might not be specific to the demo app.
We tried two video urls and the video cuts off on both. Strangely it is just for selective users (2 to be particular one using Google Pixel 6A and one using Google Pixel 8 Pro)
Video URLs: "https://cfvod.kaltura.com/pd/p/1727781/sp/172778100/serveFlavor/entryId/1_vsintz2v/v/1/ev/7/flavorId/1_6uk1wjyx/name/a.mp4" "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
MainActivityKtFile.docx VideoPlayerKtFile.docx
I have attached the sample code that was used to test which is written in Kotlin in Jetpack COmpose.
Reproduction Steps:
Open the simplified test app. Play the video in non-full-screen mode. Switch to full-screen portrait mode. Observe the video cutoff issue.
Expected result
The media plays without distortion
Actual result
The video is cut off on the top and bottom when the user switches to full-screen portrait mode, though this is not consistently reproducible across all devices.
Media
I have added two videos that show the issue being reproduced below:
https://github.com/androidx/media/assets/166735474/b0c2d02b-6e93-439a-9bd2-854a49c81fa5
https://github.com/androidx/media/assets/166735474/8d985f75-53af-4eaf-b8c2-a42d6c428ac3
Additionally, tests conducted via BrowserStack with real devices (videos attached for Google Pixel 6 Pro and Google Pixel 8 Pro) did not reproduce the issue, indicating it might be device-specific or related to specific conditions on the affected devices.
Bug Report
- [ ] You will email the zip file produced by
adb bugreportto [email protected] after filing this issue.
I came across another closed issue #1184 and then this one.
I am happy to share my findings and analysis, hoping it could help look for the real cause.
I use Media 1.3.0 and the PlayerView in a Jetpack Compose AndroidView.
I tried setting resizeMode = AspectRatioFrameLayout..*. Everything works fine, as expected, on API 33 emulator.
When I run my code on an API 34 emulator and my Pixel 7 without changing anything, not even one character, the player behaves differently. Exactly like @sunnat629 mentioned in the issue #1184, "This issue does not occur with RESIZE_MODE_FILL, but it is present in all other resize modes, including RESIZE_MODE_FIXED_HEIGHT, RESIZE_MODE_FIXED_WIDTH, and RESIZE_MODE_ZOOM."
The same unexpected behaviour was observed on VanillaIceCream emulator. That is worrying, so I believe I should raise it here.
Following the closure of case #1184, my code and the library worked as expected on API 33, so it is not a bug—even not the case on API 34 and VanillaIceCream with the library and my code unchanged.
I suggest that we can only conclude again that the library is doing what is expected from documentation (and then close the issue). I agree with this because it works on API 33.
However, I would offer a hint that, given the library's correct implementation, it works correctly on API 33 but not later versions. If the library has no API-specific code there, it can only suggest that it receives incorrect input values on API 34+, which can be related to the view/screen dimension.
I have attached the screenshots for all AspectRatioFrameLayout modes under different API versions. The observation resonates with @sunnat629 under #1184 - that only RESIZE_MODE_FILL exhibits consistent behaviour under all Android versions tested. Technically, given that the same piece of code and library version works correctly on API 33 but not later, it is more on what has been changed since API 33 rather than diving deep on the implementation of the library I believe.
Before we talk about the aspect ratio, obviously the library is picking up the wrong screen width and height on API 34, that either the video cannot be rendered, or it enlarges the video much larger than the available space for the view layout.
I can add one more observation (not being always reproducible) - on API 34+, when the screen is not rendered correctly as shown below, when I tap on the player screen to show the controller UI (which I believe it triggers a layout refresh/invalidation), the video playback will become normal again. Of course, just like what others said, changing device orientation or toggling full-screen mode can also bring the player back to the expected working state. To me, it looks pretty obvious the library is picking up wrong screen sizes - that again, I am not saying the library has a bug, but maybe the external OS functions it uses for determining the layout size.
This is what I can observe, and I believe it is the same thing as @aasthad21 reported above.
It can be a bug caused by other teams within Google, but as you can see below, it is hard to believe that this is not a bug.
(Updated 8 May 2025)
I hope this can help - so in my case, I use Compose AndroidView to host the PlayerView.
Given this does not affect API33, on API 34+, if I apply the modifier .aspectRatio(16/9f) to the AndroidView, the player would work fine. If I set it to .fillMaxHeight() or .fillMaxSize(), the result would be like the screenshots below. That means if we want to build a full-screen player, we would likely hit this problem. Some 3rd party sample codes/tutorials use .aspectRatio() so they are less likely to discover this.
Thank you for looking into this.
Emulator: Pixel 7 - API 33 - Correct Output
Sequence: ZOOM, FIXED_WIDTH, FIXED_HEIGHT, FIT, FILL
Emulator: Pixel 7 - API 34 - Distorted Output
Emulator: Pixel 7 - VanillaIceCream
@aasthad21
I have taken a look at the 2 docx files you attached and they seem the same to me. Did you mean to paste VideoPlayer Composable implementation in the second one?
https://stackoverflow.com/questions/78376656/in-pixel-7-facing-issue-like-cropping-video-with-exoplayer-when-opening-initiall
@oceanjules Attaching a full sample project that reproduces this issue. With RESIZE_MODE_ZOOM, RESIZE_MODE_FIXED_HEIGHT, or RESIZE_MODE_FIT the video does not get scaled correctly on Pixel devices. For RESIZE_MODE_ZOOM and RESIZE_MODE_FIXED_HEIGHT the screen is simply blank black screen though you can hear the video playing.
I'm using a Pixel 7 Pro (currently on Android 15 beta) for my testing. For my app, where I need the ZOOM behavior, I have reports of issues with Pixel 6, Pixel 7, and Pixel 8.
I have no issues on several other devices - Galaxy S20, A12, and Pixel 2XL
In the sample project on my Pixel 7 Pro, the video plays but only black screen is shown. If I try to replay once it's complete either by pressing play again or by pressing the seek button, it will play again as expected, but remains black. If I background the app and then foreground the app and attempt to replay the video only then am I able to see the video correctly scaled for RESIZE_MODE_ZOOM.
https://github.com/androidx/media/assets/13541377/9f5bf79f-89c5-461b-b804-1eae3ac100b1
Hey @aasthad21. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
The issue still persists. I could reproduce it on Pixel 6/7a and Pixel 8.
The issue still persists. I could reproduce it on Pixel 6/7a and Pixel 8.
From my test results, it seems to me the android os version is more of a factor than device. Which version are they running?
The bug was introduced with on of the latest Android 14 updates (this issue mentioned QPR2/March 5th).
On A13 with the Pixel 7a everything works as expected but Pixel devices with the latest Android 14 version have this issue
Duplicate of https://github.com/androidx/media/issues/1237