ReVanced / revanced-patches

🧩 Patches for ReVanced
https://revanced.app
GNU General Public License v3.0
2.5k stars 291 forks source link

bug(YouTube - Background playback): Miniplayer does not play in background after playing a Short #3895

Open dib12 opened 1 week ago

dib12 commented 1 week ago

Bug description

Way to trigger the bug:-(check video) Disable short background playback. Play any video. Keep it in Minimize mode. Play a short.press back. Resume the Minimize video.then video no longer play in background.

If short background playback enabled, video play in pip and there is no background button in pip screen for that video (not short video ) with same trigger.(See second photo)

Error logs

Solution

Removing pip for short may work.

Additional context

https://github.com/user-attachments/assets/3a1965ee-b6e0-4fb0-8281-afb1734e7239

Image

Acknowledgements

LisoUseInAIKyrios commented 1 week ago

Fixing the first issue requires figuring out a better way to know if a Short is currently on screen and playing. The current approach fails for situations like this.

The second issue of the missing audio only background playback button (headphones icon), appears to be a YouTube bug.

dib12 commented 1 week ago

@LisoUseInAIKyrios can you add a commit here to revert background playback for short.I will cherrypick and will build patches.rvp for test.

LisoUseInAIKyrios commented 1 week ago

Try reproducing the issue again, but before changing to background mode maximize the video to full screen (or maximize to the regular player, and not the miniplayer).

If the regular video is not in miniplayer mode then background playback should behave correctly. This specific issue has been present for a long time and is not new.

Reverting the Shorts background playback change won't fix this.

dib12 commented 1 week ago

The only way background playback works again if I play another video

Edit: I want to test with revert that commit as headphone button changes to previous button in short video pip.but after press back,play the minimised video its not restores headphone button in pip.Need to change the video for restore background playback and headphone button in pip

LisoUseInAIKyrios commented 1 week ago

You can try reverting commit https://github.com/ReVanced/revanced-patches/commit/7db1a7751dc47c4e36096fbdc2b3761b0ae11ccb but it will not fix this specific use case (going to background playback with miniplayer after opening a Short). This bug has been present for a long time.

dib12 commented 1 week ago

Due to update in patcher version after that commit i failed to revert it.(Not much knowledge about these)

dib12 commented 1 week ago

@LisoUseInAIKyrios Ohh right .Checked with old patch. But one good thing in old patch is video atleast go to pip (although background botton is not there)

But in new patch video stops play (not playing in pip atleast)when disable background for short. If background playback for short enabled, minimized video plays in pip

dib12 commented 1 week ago

Another thing I got is If I disable pip in general settings , with old patches video plays in background without any issue. But with new patch video stops playing.

I think its better to revert that.

LisoUseInAIKyrios commented 1 week ago

If you don't want background play then don't include the patch.

When using the old patches you did not follow the same reproduction steps. This issue only shows up when:

  1. Open a regular video
  2. Open a Short (without closing the regular video)
  3. Close the Short
  4. Resume playback of the original video
  5. Put the video into minimized (Miniplayer) mode
  6. Change apps
  7. Video does not play in background mode

If these exact steps are not followed, then the bug does not occur.

This bug has been present for a long time. This thread is starting to turn into a loop of repeating the same information over and over.

inotia00 commented 1 week ago

I implemented a hook to detect if the Shorts player view (R.id.reel_watch_player) is attached or detached from the Windows

Since this is implemented as a listener, it can detect if the Shorts player is open or closed more quickly and accurately than the PlayerType hook

I applied this to my patch a little over a month ago, and it seems to work fine with background playback patch (general video) and the hide Shorts navigation bar patch

My patch was only tested on YouTube 19.16.39, so I haven't tested it on the latest YouTube (including the Shorts background playback patch)

https://github.com/inotia00/revanced-patches/blob/807494f8a7d09a7b9d6c03364ed52df682007d57/src/main/kotlin/app/revanced/patches/youtube/utils/playertype/PlayerTypeHookPatch.kt#L70

https://github.com/inotia00/revanced-integrations/blob/4f8d7c95240b398a103ea60baa149a19a8c63c0f/app/src/main/java/app/revanced/integrations/youtube/patches/utils/PlayerTypeHookPatch.java#L39