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

Closing expanded YouTube video doesn't correctly delete/stop the MPRIS connection #5364

Open
zjeffer opened this issue Dec 26, 2021 · 8 comments

Comments

@zjeffer
Copy link

zjeffer commented Dec 26, 2021

What's the problem?

On Linux, I manage (play/pause) my media using the media keys on my keyboard. Say a video is playing in Firefox, I can play/pause even when the window is not in focus. Firefox added functionality a couple of months ago to use hardware media keys to control players like this.

When expanding a video, RES creates such a player that Firefox can control. Here's an example of such a connection seen in qdbusviewer:

image

As you can see in the image, I can control the video (play/pause/next/prev/...) and request information about it (PlyaBackStatus, Metadata, ...)

The problem is:

  • When closing an expanded video while it is still playing, the player still reports as "Playing", while it should be "Stopped". Play/pause has no effect, it always reports as "Playing" even though I just closed it and it isn't actually playing anymore.
  • When closing an expanded video while it is paused, PlaybackStatus is "Paused", but should also be stopped. Play/pause also has no effect.
  • Opening a closed YouTube expando (that was still playing) starts the video from the beginning again (expected behaviour), but the MPRIS connection of the previously opened video is still being reported as "Playing". No new MPRIS connection is opened for the reopened expando.
  • After this, opening another YouTube expando will replace the MPRIS connection, but upon pausing this video (either using hardware keys or just clicking the buttons on the video), the previously closed player (first bulletpoint) will be the MPRIS connection that's visible in qdbusviewer again.

This means that when I open a YouTube video and then close it, media in that tab won't be controllable at all, because the tab thinks the first YouTube player is still playing. Only remedy is closing the tab and opening another one.

I use a script to always play the last paused mediaplayer (Spotify, Firefox, etc), and always pause the currently playing mediaplayer. When the player is "Playing" (first bulletpoint) or "Paused" (second bulletpoint), the script tries to play/pause the latest player it but nothing happens. This is kind of hard to explain so if I need to make a video showcasing how it works I can do that.

I believe the fix for this is to actually send the "Stop" signal to the MPRIS player when closing it (or completely delete the player?). That way, my script will just ignore it.

Are there any related posts in https://github.com/honestbleeps/Reddit-Enhancement-Suite/issues or /r/RESissues?

What other browser extensions are installed?

  • uBlock Origin
  • SponsorBlock
  • DuckDuckGo Extension
  • Poper Blocker
  • YouTube enhancer
@zjeffer
Copy link
Author

zjeffer commented Dec 28, 2021

I believe the fix would be to change the pausecommand to a stopcommand here: https://github.com/honestbleeps/Reddit-Enhancement-Suite/blob/master/lib/modules/showImages.js#L1652

I've looked around in the code but I can't find what this command should be, and my knowledge of TypeScript is very limited. I hope someone else can fix this.

@zjeffer
Copy link
Author

zjeffer commented Jan 2, 2022

I just noticed the same behaviour in Windows. Very annoying.

@indivisible
Copy link

Seems to be a firefox bug

Extensions don't have dbus access (though native messaging helpers can cheat that), so it's not RES' fault. The player controls are even stuck between tab reloads!

@zjeffer
Copy link
Author

zjeffer commented Jan 19, 2022

@indivisible Thanks for creating a bug report! I never noticed it on another site, so naturally I thought it would be RES's fault.

However, I think stopping the player before removing the DOM would fix this as well. Knowing Firefox, fixing that bug will be pretty slow. Is this something RES devs could implement in the meantime, or should I close the issue?

@indivisible
Copy link

However, I think stopping the player before removing the DOM would fix this as well

Just tested this, and no, it does not work. I tried the YT api's stopVideo and destroy functions and neither help

@zjeffer
Copy link
Author

zjeffer commented Jan 20, 2022

Weird, when I press the stop button on my keyboard (which sends the MPRIS Stop method), the video stops and I can then close it fine without the bug happening.

@indivisible
Copy link

Weird, when I press the stop button on my keyboard (which sends the MPRIS Stop method), the video stops and I can then close it fine without the bug happening.

Yeah, it's a weird bug. I've not found anything that can be done to youtube embeds so far to fix this. I don't even know what's special about youtube's player that causes the bug: I've been unable to recreate the bug with simple video-tag-in-iframe so far

@ElijahPepe
Copy link
Contributor

#5397 should fix this.

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

No branches or pull requests

3 participants