Skip to content
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

fix(YouTube): Fix player button fade out animations #4469

Merged
merged 13 commits into from
Feb 19, 2025

Conversation

MarcaDian
Copy link
Contributor

@MarcaDian MarcaDian commented Feb 16, 2025

Fixing overlaying chapter title on disappearing bottom buttons.

Previously discussed here

Before

VID_20250217_010347.gif

After

VID_20250217_010455.gif

@LisoUseInAIKyrios
Copy link
Contributor

Does requiring a restart improve anything? Or is anything simpler if a restart is required?

@LisoUseInAIKyrios
Copy link
Contributor

The fade out immediately (when tapping the video player overlay) should be PlayerControlButton#fadeOutImmediate

Currently it's not used though.

@MarcaDian
Copy link
Contributor Author

MarcaDian commented Feb 16, 2025

No restart required. The button first becomes invisible and then disappears. The animation is displayed correctly and the chapter_title does not overlap the button.

@LisoUseInAIKyrios
Copy link
Contributor

If it's simpler then can do a little copy paste of these changes to the SponsorBlock buttons. Can figure out refactoring to a common class later (or never if nobody cares enough).

@MarcaDian
Copy link
Contributor Author

As I wrote above, that's what I did, I just copied the same code to SB. But for some reason after that the animations started jumping again and I reverted and left only the changes to the bottom buttons.

@MarcaDian
Copy link
Contributor Author

MarcaDian commented Feb 16, 2025

Found only one bug. If you minimize the video in the in-app-miniplayer, and disable any button, then Utils.runOnMainThreadDelayed(() does not work and an empty space remains (View.GONE does not apply)

Will need to restart the application. It seems to me that such a case is very rare, so I do not know whether it is necessary to pay attention to it.

SB buttons decided to stick with the old animations, as the new code causes the bottom buttons to blink.

@LisoUseInAIKyrios
Copy link
Contributor

Yeah that issue seems minor enough that it can be ignored.

@MarcaDian
Copy link
Contributor Author

Another way out of this situation is to require a restart when changing the visibility status of the buttons.

@MarcaDian MarcaDian marked this pull request as ready for review February 17, 2025 07:52
@LisoUseInAIKyrios LisoUseInAIKyrios changed the title fix(YouTube): Fixing the animations of the bottom buttons fix(YouTube): Fix player button fade out animations Feb 17, 2025
@LisoUseInAIKyrios
Copy link
Contributor

I tried (again) to fix the wrong fade out duration when taping the overlay (it fades out faster), but gave up after failing to find a simple solution.

For now this is as good as it'll get, and an improvement over what currently is used.

@MarcaDian
Copy link
Contributor Author

MarcaDian commented Feb 17, 2025

I had an idea, why not add these bottom buttons to the new container inyoutube_controls_cf_fullscreen_button.xml (v19.16+).
cf_fullscreen_button is currently in ViewStub

<ViewStub android:id="@id/youtube_controls_fullscreen_button_stub" android:layout="@layout/youtube_controls_fullscreen_button" android:inflatedId="@id/fullscreen_button" android:layout_width="60.0dip" android:layout_height="60.0dip" yt:layout_constraintBottom_toTopOf="@id/quick_actions_container" yt:layout_constraintRight_toRightOf="parent" />

So that they are in the container where cf_fullscreen_button is now, if I understand correctly, they must inherit its behavior.
Although maybe I'm wrong.

It is even noticeable that the cf_fullscreen_button animation adapts to the tap speed, and the current implementation does not.

@LisoUseInAIKyrios
Copy link
Contributor

Could try and see.

I previously tried adding the buttons to a different layout file (I don't remember which file), but whatever file I used had issues with the chapter titles text overlapping the buttons.

@LisoUseInAIKyrios
Copy link
Contributor

I'm looking at adding the buttons to the fullscreen stub, but I don't think that will easily work.

It appears the fast fade out is applied to the fullscreen button itself and not a container view or anything that can be used to inherit the behavior to the RV buttons.

@MarcaDian
Copy link
Contributor Author

Yes, it's not easy. I tried, but I had problems inflating the ViewStub, the buttons wouldn't initialize. The documentation says that you need to inflate() first so that the buttons are available later. After some actions the buttons still could not be initialized. It's difficult for me.

@LisoUseInAIKyrios
Copy link
Contributor

Is this ready to merge? If a simple fix for the fast fade out can be figured out it can be another PR.

@MarcaDian
Copy link
Contributor Author

MarcaDian commented Feb 18, 2025

Yes, ready.

@MarcaDian
Copy link
Contributor Author

MarcaDian commented Feb 18, 2025

Studying the question, I came across interpolation animations, namely, for example, AccelerateDecelerateInterpolator . What do you think, maybe it is also present? i tried

fade.setInterpolator(new AccelerateDecelerateInterpolator());

I think it has gotten better, but I state the fact that the duration from resources is not suitable, my animations are longer than they should be.
I want to transfer the duration value to the settings in order to select them in real time.
At the same time, it is still possible to merge this PR and continue the search for a solution to problems with animation.

@LisoUseInAIKyrios
Copy link
Contributor

That is likely the animation type. It's not an Animation object because with 1717a64 I tried overriding animationStart and it was never called.

@LisoUseInAIKyrios
Copy link
Contributor

The fade out duration from the resources is 700ms.
Previously this PR was hard coded to 600ms, but I'm seeing the opposite and the fade out is slightly too fast with 600ms.

@LisoUseInAIKyrios
Copy link
Contributor

LisoUseInAIKyrios commented Feb 19, 2025

Looking at the gif's in the first post, 600ms does appear to be too fast.

Here's the last two frames and the RV buttons are faded out more than the fullscreen button and the chapter title.
frame_58_delay-0 1s
frame_59_delay-0 1s

@MarcaDian
Copy link
Contributor Author

Since it is not possible to intercept the animations of the fullscreen button, I tried to copy its behavior. But most likely, several animations are composed there, which are also supplemented with interpolation (which I wrote about above).

I meant the animation that after a tap on the screen, that's what I want to copy, at the moment the fadeout animation of the button and all containers in the player is the same, and revanced* buttons fade later and appear with a delay after a tap than the fullscreen button.

I previously assumed if the buttons were integrated into the ViewStub (youtube_controls_fullscreen_button.xml) they would also use the fullscreen button behavior. But I lost a lot of time, but I did not succeed, I lack experience.

Currently, this PR is better than it was.

PS: I think you understood me (I use a google translator, sometimes it does not convey what I mean)

@LisoUseInAIKyrios LisoUseInAIKyrios merged commit bf8e775 into ReVanced:dev Feb 19, 2025
1 check passed
github-actions bot pushed a commit that referenced this pull request Feb 19, 2025
# [5.13.0-dev.3](v5.13.0-dev.2...v5.13.0-dev.3) (2025-02-19)

### Bug Fixes

* **YouTube:** Fix player button fade out animations ([#4469](#4469)) ([bf8e775](bf8e775))
@MarcaDian MarcaDian deleted the fix_bottom_buttons branch February 19, 2025 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants