bundit / kord

Spotify, Soundcloud, and YouTube all in one website!
https://www.kord.app
MIT License
646 stars 73 forks source link

UI "playing" state out of sync when playback is controlled by global media keys #48

Closed andrewbrey closed 2 years ago

andrewbrey commented 3 years ago

Browser: Firefox 85.0.1 OS: Linux (Ubuntu)

All evergreen browsers now support "global media hotkey" playback control via the https://developer.mozilla.org/en-US/docs/Web/API/MediaSession API, and so it is possible to play/pause Kord globally with a keyboard media key, but as of today the current playback state becomes out of sync with the UI when media keys are used to control playback.

It would be great if Kord accurately reflected in the UI whether or not media is currently playing - this is essentially strictly aesthetic, so certainly not a critical or breaking issue!

I didn't look too deeply into how this would work, but I do know that YouTube for instance does correctly reflect the current playback state in its play/pause icons in the player, so I know there is some way to listen for this change as it comes from either the global media controls or the player controls themselves.

Thanks for the neat app, I'm enjoying using it :+1:

bundit commented 3 years ago

@andrewbrey thanks for reporting

I've been trying to figure out this very issue. It seems that sometimes while playing Spotify tracks, the browser loses context of which audio stream is playing from where and the media keys stop being detected. I think it has something to do with the fact that the Spotify Web Playback SDK initializes the player in an iframe but I haven't been able to reproduce it consistently yet