The audio demo makes me think of Bandcamp which will pause music that you're playing if another Bandcamp tab starts playing a song separately. Must be a similar mechanism under the hood
The audio demo makes me think of Bandcamp which will pause music that you're playing if another Bandcamp tab starts playing a song separately. Must be a similar mechanism under the hood
This is likely done with the WebLocks API
That doesn't allow signaling another tab, does it?
> The Web Locks API allows scripts running in one tab or worker to asynchronously acquire a lock, hold it while work is performed, then release it. While held, no other script executing in the same origin can acquire the same lock, *which allows a web app running in multiple tabs or workers to coordinate work and the use of resources.*
source: https://developer.mozilla.org/en-US/docs/Web/API/Web_Locks_A...
I read that, but how can that API be used to notify the original tab to stop playing?
It has the ability to "steal" lock from another tab. Once tab loses a lock, it can pause the playback.
As far as I can tell, the original tab isn't notified when its lock is stolen. So again, how would the original tab be notified?