Mastermindzh / tidal-hifi

The web version of Tidal running in electron with hifi support thanks to widevine.
Other
918 stars 53 forks source link

Media key integration and playback status issues with tidal-hifi #376

Closed Darogirn closed 2 months ago

Darogirn commented 3 months ago

Environment:

Operating System: Nobara Linux 39 Desktop Environment: KDE Plasma 6.0.3 Qt Version: 6.6.2 Kernel Version: 6.7.6-201.fsync.fc39.x86_64 (64-bit) Graphics Platform: Wayland Processors: 16 × AMD Ryzen 7 5700X 8-Core Processor Memory: 15.5 GiB RAM Graphics: AMD Radeon RX 6750 XT tidal-hifi Version: 5.9.0 (Flatpak)

Issue Description: The pause/play media key on the keyboard is not working as expected with the tidal-hifi app. The key only functions once to either pause or play a song. After the initial use, the pause/play key stops working, and I have to manually control playback using the media control widget or the tidal-hifi app itself.

Additionally, when the pause/play key is used, the media control widget in the taskbar or notification area does not accurately reflect the current playback status. For example, if a song is paused using the media key, the media control widget continues to show the song as playing, even though the audio has been paused.

Steps to Reproduce:

Launch the tidal-hifi app. Start playing a song. Press the pause/play media key on the keyboard. Observe that the song is paused or played as expected. Press the pause/play media key again. Note that the media key no longer functions to pause or play the song. Also, observe that the media control widget in the taskbar does not reflect the correct playback status after using the media key.

Expected Behavior: The pause/play media key should work consistently to control playback in the tidal-hifi app, without any limitations on the number of times it can be used.

Please let me know if you need any further information or if you have any additional details that could help diagnose and resolve this issue.

TheRockYT commented 3 months ago

Thanks @Darogirn for the detailed description. I can reproduce the problem on GNOME.

I found that the global shortcut in electron, which is currently used to provide the functionality, doesn't work well with the media keys, but it does work consistently with other shortcuts like CmdOrCtrl+x.

I also saw that there is a custom implementation for media sessions in the preload script, which is usually used to provide the shortcuts and OS integration for media playback on websites.

Media Session API: mozilla.org

There is already an implementation for media sessions on listen.tidal.com, but both (custom and official) are disabled by the disable-features -> MediaSessionService flag, as a fix for #338.

I don't use the MPRIS interface so I removed the global shortcuts and custom media sessions, and enabled the MediaSessionService flag in my fork. This restores the behaviour as in Chromium, but may break some parts of MPRIS.

I will be testing my changes for a few days and may submit a PR, trying not to break issues that have already been solved.

Darogirn commented 3 months ago

Hey @TheRockYT, thanks so much for the detailed response. I really appreciate you taking the time to explain what's going on and the work you're doing to try and fix this issue. It's helpful to understand the context behind the problem with the pause/play media key functionality. I'll be eager to see how your testing goes with the changes you mentioned.

Mastermindzh commented 3 months ago

Thanks for looking into it @TheRockYT, I am willing to revert/reconfigure the fix for mpris if it breaks this too. The fixes for MPRIS didn't lead to the desired result and can always be put behind a few flags.

SonGoku90 commented 2 months ago

Hello, I have the same problem with shortcuts in Fedora 40 gnome on Wayland.

Mastermindzh commented 2 months ago

Fixed in 5.11.0