-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Prevent jumping of the player and wrong padding on devices with cutout #4154
Conversation
app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java
Outdated
Show resolved
Hide resolved
That commit actually makes the player off-center for me while using a Poco F1. It was perfect before the commit as it was almost identical to the official YouTube app, minus pinch to zoom. Aligning to the notch means you'll probably lose some of the image. Like in my case it's now off-center and I lose some of the image on the right side of my screen due to the phones rounded corners. |
@blackbox87 You compared with 0.19.8 which doesn't make sense. In 0.19.8 the app uses default mechanism of handling the cutout, everything is done by Android. On the newest version there is no way to give this job to Android because of the need to use Fragment instead of an Activity. So, just compare with the latest apk from the link. More info about the problem the PR trying to fix can be found in #4040 |
Sorry about that. I haven't been testing debug versions for a while now, so I didn't think to compare it to a different debug build. But I can confirm that the builds by @B0pol all have the same issue. It's awful. You're not supposed to align videos to the cutcout while using landscape because cutcouts come in many different sizes. If you do then you'll likely end up with off-centered videos and only having rounded corners on one side of your screen. That's why YouTube, VLC & many other players don't do anything about the notch and always center the videos to fit. |
fe90638
to
b8a35e9
Compare
// Prevent jumping of the player on devices with cutout | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | ||
activity.getWindow().getAttributes().layoutInDisplayCutoutMode = | ||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to the following and it fixes landscape too.
// Prevent jumping of the player on devices with cutout
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
if (isLandscape()) {
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
} else {
activity.getWindow().getAttributes().layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this but in this case a title and a description will be hidden under possible cutout from top right corner (in landscape orientation it will be in top left corner). I'm not sure about how much devices have such cutout but it's not an ideal choice anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually a separate issue that's caused by the status bar height (and navbar height?) not being accounted for while viewing a video in landscape. So I'm currently trying to work out the best way to center the controls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know that someone cares about it. Not only landscape mode has the problem with the centering but vertical videos too.
@avently Check out my commit. It should give you perfectly centered videos and all of the controls will have the correct padding. And although it's unrelated to this problem I noticed that screen rotation doesn't always behave correctly.
Previously NewPipe would return you to your default orientation, but now you'll remain stuck in landscape and NewPipe's fullscreen button won't do anything no matter how many times you press on it. So as it seems buggy I made this change which restores the original behaviour. |
@blackbox87 I didn't look closely on your changes but looks like the changes depend on this PR. And you say now everything is fine. So we can merge this PR and then to wait your PR, right? About autorotation issue: can you make a PR too? |
It could be done that way or you could just copy my changes into your branch. I'm happy with whatever as long as this gets fixed.
I'd like to know if it's the intended behaviour or not first. Maybe @Stypox or @TobiGr can comment? It's possible that they want NewPipe to remain in landscape mode, but having the button not do anything when you disable auto-rotate seems like a bug either way. It should always be able to toggle between portrait and landscape. |
@blackbox87 I prefer to maintain only my code. So better to have your code inside your PR. About autorotation: this is my code that makes such situation so if your solution fixes it just make a PR. For me it was like a rare case (when you lock orientation while in landscape) and I just skipped that case |
Fair enough. If someone merges this in then I'll update my fork and create a pull request.
Well there's two ways to fix the issue.
I'm not familiar with the code, which is why I went with the first option and made NewPipe behave as it used to. But I think fixing the button might actually be the better solution. |
@blackbox87 second way is not an option at all. So, yeah, the first way is what we need. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, though I don't have a device to test this on. But if @blackbox87 says he has a fully working solution based on this one I'd merge right away, also to prevent rebasing issues. Thank you @avently ;-)
@blackbox87 thank you for your investigations, as soon as this PR will get merged feel free to create two separate PRs for cutout and rotation. I think your rotation approach is right, obviously having a button doing nothing is a bad idea and the previous behaviour was ok. Thanks :-D
I've actually figured out how to fix the button, although @avently said that it wouldn't be an option. So we could have NewPipe remain in landscape and only change to portrait when the fullscreen button is pressed again. Personally I think that might be the better solution too. |
@blackbox87 yeah, do as you said ;-) |
thank you |
You're welcome. Can wait to see a fix for centering from @blackbox87 |
What is it?
Description of the changes in your PR
On devices with cutout there is a "jump" when you are in multiWindow mode or when you're watching vertical video in fullscreen. This PR fixes that jump (the first commit).
On the same devices there is a problem related to top padding on vertical videos in portrait in fullscreen. This is more interesting because a couple hours ago I thought I will not be able to fix it. This problem makes situation when the center of the player is not in the center of the screen. After hours trying I installed the app on my phone and the issue is fixed actually (same Android version but different result). So I have no idea will my method (from the second commit) work on user's devices or not. I think the issue is still here but on devices with non-standard screen ratio. But I don't know how to fix it. You can merge the PR as is or merge only first commit, or drop it.
In short:
Everyone who has a device with a hole, cutout, whatever check this build in vertical videos in landscape, in portrait, in multi window mode, check non-vertical videos too.
Fixes the following issue(s)
partially fixes #4040
Testing apk
app-release-final.zip
Agreement