Skip to content

Fix: Issue where upon video completion in fullscreen landscape, the device does not revert back to portrait mode#13178

Open
volatilespecial wants to merge 1 commit intoTeamNewPipe:devfrom
volatilespecial:work/fix/13057
Open

Fix: Issue where upon video completion in fullscreen landscape, the device does not revert back to portrait mode#13178
volatilespecial wants to merge 1 commit intoTeamNewPipe:devfrom
volatilespecial:work/fix/13057

Conversation

@volatilespecial
Copy link

What is it?

  • Bugfix (user facing)

Description of the changes in your PR

Bug fix with the player in fullscreen landscape. When the video ends, the player now exits fullscreen mode with the correct orientation.

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions bot added the size/small PRs with less than 50 changed lines label Feb 2, 2026
@volatilespecial volatilespecial marked this pull request as ready for review February 2, 2026 10:27
@volatilespecial
Copy link
Author

I forgot to remove the Debug part. I'll do that now.

@ShareASmile ShareASmile added bug Issue is related to a bug player Issues related to any player (main, popup and background) labels Feb 2, 2026
@ShareASmile ShareASmile added the ready for review Most of the work is done, PR is now ready for a review label Feb 24, 2026
Comment on lines +948 to +951
if (player.getCurrentState() == STATE_COMPLETED) {
player.getFragmentListener()
.ifPresent(PlayerServiceEventListener::onScreenRotationButtonClicked);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well you are not checking if you really need to do the rotation.

It works fine if you had vertical orientation before entering the full-screen so rotation in the end will return you to starting position. But if before video you had horizontal orientation, rotation in the end will rotate screen to vertical position. So it is not solving the bug but transfers it from vertical to horizontal orientation...

I don't know if there is any kind of tracking of previous rotation and not sure how it worked (if it really worked) before 0.28.1 mentioned in the linked issue or not but you need to track it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into it. Thanks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I may have found a fix for that.
So from what I understand, when the screen orientation is locked, the video starts in portrait mode and goes into landscape mode when the fullscreen button is clicked. At the end of the video, it goes back to portrait mode like it was before and exits fullscreen mode.

When the screen orientation is unlocked, if the video ends while in portrait or landscape mode, it should remain in that mode because the phone is still in portrait or landscape.

Now by default, it exits fullscreen mode no matter if it locked or unlocked. I'm not sure if that's a wanted behavior by whoever wrote that but at least the orientation seems to be fixed.

For the fix I checked if the orientation is locked or unlocked before making the rotation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are 2 options:

  • The one you already implemented, to always rotate back to portrait if the screen orientation is locked
  • only rotate back to portrait if the orientation is locked and the option "Start main player in fullscreen" is enabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are 2 options:

* The one you already implemented, to always rotate back to portrait if the screen orientation is locked

It is not "always rotate back to portrair", it is "always rotate regardless original orientation"

* only rotate back to portrait if the orientation is locked and the option "Start main player in fullscreen" is enabled.

Does it have any sense at all?

Copy link
Contributor

@dustdfg dustdfg Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@volatilespecial You shouldn't always rotate, you should rotate smartly

For the fix I checked if the orientation is locked or unlocked before making the rotation.

What it changes? Yeah it probably should also be done

For following assume that screen rotation is locked:


With no rotation on fullscreen exit: (current behavior)

Vertical position. Open fullscreen -> horizontal position. Exit fullscreen -> horizontal position (bug)
Horizontal position. Open fullscreen -> horizontal position. Exit fullscreen -> horizontal position


With always rotate on fullscreen exit: (your PR)

Vertical position. Open fullscreen -> horizontal position. Exit fullscreen -> vertical position
Horizontal position. Open fullscreen -> horizontal position. Exit fullscreen -> vertical position (bug)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I'll look into it and fix that.

@vmarinescu
Copy link

Personally, I would recommend adding a configuration option to rotate back to portait on video end. Perhaps only show it in case the option "Start main player in fullscreen" is enabled.

@dustdfg
Copy link
Contributor

dustdfg commented Mar 2, 2026

Personally, I would recommend adding a configuration option to rotate back to portait on video end. Perhaps only show it in case the option "Start main player in fullscreen" is enabled.

It is a one more option. We try to constraint amount of options because most of it won't be discovered by users and moreover. Additionally the behavior itself is considered buggy by all people. Especially because it not only turns the screen for newpipe but turns screen for whole android so it means you mess with user expectations that your app doesn't stab you...

@vmarinescu
Copy link

I understand your point. Would just be great if advanced users could achieve their desired behaviour without actually forking the repo. Do you have any suggestion for me?

@dustdfg
Copy link
Contributor

dustdfg commented Mar 4, 2026

  1. Please use "normal" commit history it is easier this way to review
  2. Player is a mess and logic of screen rotation is actually mixed with logic when you need to do that rotation... It is too much for me to accommodate all the states in my mind (including tablet and tv)
  3. I am stupid so I am stopping pretending that I can "review" this PR... So I can only wish you to be patient when someone who knows player will come and review this
  4. I've tried to investigate it a bit more and I think that maybe you should look at how fullscreen button is implemented too. Maybe they could even share the same implementation but not sure for 100%
    binding.screenRotationButton.setOnClickListener(makeOnClickListener(() -> {
    // Only if it's not a vertical video or vertical video but in landscape with locked
    // orientation a screen orientation can be changed automatically
    if (!isVerticalVideo || (isLandscape() && globalScreenOrientationLocked(context))) {
    player.getFragmentListener()
    .ifPresent(PlayerServiceEventListener::onScreenRotationButtonClicked);
    } else {
    toggleFullscreen();
    }
    }));
  5. Good luck!

@volatilespecial
Copy link
Author

Alright, so I've cleaned the commit history as requested. This fix reverts the orientation back to portrait after the video ends by tracking the orientation everytime toggleFullscreen is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue is related to a bug player Issues related to any player (main, popup and background) ready for review Most of the work is done, PR is now ready for a review size/small PRs with less than 50 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fullscreened video does not revert to portrait view on completion

4 participants