steve228uk / YouTube-Music

:musical_note: A Mac app wrapper for music.youtube.com
https://ytmusic.app
MIT License
2.77k stars 202 forks source link

(FIX) Display the correct menu title for play/pause #178

Open sprejjs opened 1 year ago

sprejjs commented 1 year ago

Problem

The dock and playback menu item was always displaying "Play" as the first option regardless of the current state of the playback.

Fixes #112

Proposed solution

Looks like the dock menu used to display the correct title at some point but then got broken due to the change on YouTube's side.

After reviewing the code, I've realised that the current "isPlaying" value is read from the webpage once a second by comparing the play button title to the string constant. It looks like the constant name was changed from YT_PAUSE to PAUSE breaking the implementation.

Screenshot 2022-11-27 at 07 13 56

I fixed the implementation by updating the name of the constant in the custom script.

The main menu item on the other hand was always displaying the "Play" option regardless of the current playback. I've used the same logic to update the menu item as well.

Evidence of testing

Tested by running the app on my machine.

Before After
Screenshot 2022-11-27 at 07 09 39 Screenshot 2022-11-27 at 07 10 14