PreMiD / Presences

🛒 Storage for Presences located at our Presence Store.
https://premid.app/store
Mozilla Public License 2.0
591 stars 1.29k forks source link

YouTube Music | music.youtube.com - doesn't display songs on Firefox #8574

Closed dlsf closed 3 months ago

dlsf commented 3 months ago

Steps to Reproduce

  1. Open and play any song on YouTube Music via Firefox
  2. Check Discord presence

Expected Behavior

Presence shows a Playing status with the song name

Actual Behavior

Presence is stuck on "Browsing" or "Browsing Home"; does not display the song that's being played

Page URL

Any song, e.g. https://music.youtube.com/watch?v=fDuNxaxnORM

Screenshots

image

Operating System

endeavourOS / Linux

Browser and Version

Firefox 128.0

Additional Comments

I've heard from at least one other person that they're experiencing similar issues

itsmeeudrino commented 3 months ago

Can't replicate, presence seems to work like expected on Firefox 129.0b6 & PreMiD 2.6.4

theusaf commented 3 months ago

Duplicate of #7094

dlsf commented 3 months ago

The console output is completely different and I'm not using an external PreMiD software, so no, it's not a duplicate of that 2 year old issue. I can provide logs if it helps.

Can't replicate, presence seems to work like expected on Firefox 129.0b6 & PreMiD 2.6.4

Did you test it on Linux / Arch?

dlsf commented 3 months ago

It should also be noted that the YT Music presence is the only one I'm having issues with (Twitch and GitHub work just fine) and that restarting Discord/Firefox/the OS or reinstalling the presence/PreMiD doesn't fix the issue

theusaf commented 3 months ago

If there are any relevant logs you can provide, that would be helpful

dlsf commented 3 months ago

Output from developer tools console: https://haste.devcord.club/xevabevufi.makefile More verbose browser console: https://haste.devcord.club/ripagupeji.pl (first few lines are probably from before I refreshed the YTM tab; removed a few lines from unrelated extensions)

I believe there are some TypeErrors in the presence.ts?

Slowlife01 commented 3 months ago

Can you see which selector returns null

dlsf commented 3 months ago

I noticed that the selector is working once the page has fully loaded, so I tried isolating the issue and found out that it was caused by a browser addon called "Plasma Integration", which aims to add better support for Firefox to the KDE Plasma desktop environment. This means that this issue is technically resolved, and I apologize for not doing this from the start.

However, the selector document.querySelector('ytmusic-player-bar[slot="player-bar"]') still appears to be null when the page is refreshed, and another error, which is also included in the logs above, popped up: TypeError: n is undefined in line 539 (timestampFromFormat() method in PreMiD's Presence.ts [not the YouTube Music presence.ts file]).

At the very least, it doesn't display any timestamps on my YouTube Music presence even though timestamps are enabled in the presence settings, but I suppose this is a different issue and I can't confirm if it's directly related to the error message mentioned above or even a problem with the YouTube Music presence and not PreMiD itself. However, I was able to replicate the issue on a new Firefox installation with only PreMiD installed this time around.

Since this is not directly related to the problem that was initially brought up: if you consider this issue done from your point of view, you're more than welcome to close this. However, I would much appreciate further assistance.

itsmeeudrino commented 3 months ago

The KDE extension seems to be overwriting the global mediaSession 's playbackState property

which the presence uses to determine whether a song is loaded or not.

The YT Music presence expects playbackState to be either playing or paused when a song is loaded, which the plasma extension overrides to always be none

for reproduction, go to a song's page on YT music, after the song is loaded, navigator.mediaSession.playbackState should be equal to "playing" or "paused".

then do the same with the plasma extension enabled, playbackState should be equal to "none".

note: make sure the script is running in the PreMiD extenson scope

dlsf commented 3 months ago

@itsmeeudrino That makes sense, thank you. I wonder why they overwrite this value…

Do you also have an idea what could prevent the presence's timestamps from showing up, by any chance?

itsmeeudrino commented 3 months ago

Do you also have an idea what could prevent the presence's timestamps from showing up, by any chance?

if you're using Watching or Listening statuses, timestamps don't show up on desktop (app or web) which i believe is a bug in discord because it shows up as expected on mobile.

i also noticed that YT Music presence errors out in updateSongTimestamps while the player is loading (querying #left-controls > span), however once the player is loaded the presence should be able to read timestamps. https://github.com/PreMiD/Presences/blob/fc77e77fa193072d7091715e14934db5d4e572cd/websites/Y/YouTube%20Music/presence.ts#L279-L297

dlsf commented 3 months ago

Oh wow, you're right, it displays them on mobile. What a weird issue, from a DE browser extension problem to a Discord bug... Well, this explains everything, thank you! :)