Bug 414811

Summary: Plasma browser integration playlist controls aren't working on Bandcamp
Product: [Plasma] plasma-browser-integration Reporter: Shmerl <shtetldik>
Component: FirefoxAssignee: Kai Uwe Broulik <kde>
Status: RESOLVED INTENTIONAL    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Shmerl 2019-12-04 03:19:23 UTC
I'm using Plasma browser integration 1.7 with Firefox 72.0b1 on Debian testing (Plasma 5.14.5, which is somewhat outdated).

I noticed that when opening a Youtube playlist, Plasma browser integration media controls shown in system notification area work for advancing backward and forward in the playlist. But when doing it for example on Bandcamp, that playlist functionality doesn't work.

I suppose it requires some site specific logic to function?
Comment 2 Kai Uwe Broulik 2019-12-04 07:39:14 UTC
This extension doesn't do any site-specific code. The website would need to register a callback like so:

if (navigator.mediaSession) {
    navigator.mediaSession.setActionHandler("nexttrack", () => {
        // switch to next track
    });
}
Comment 3 Shmerl 2019-12-04 07:47:10 UTC
(In reply to Kai Uwe Broulik from comment #2)
> This extension doesn't do any site-specific code. The website would need to
> register a callback like so:
> 
> if (navigator.mediaSession) {
>     navigator.mediaSession.setActionHandler("nexttrack", () => {
>         // switch to next track
>     });
> }

Is that some kind of standard? Why such specific callback and not something else? I.e. I can propose that to Bandcamp, but it must be something standardized, to make it convincing.
Comment 5 Shmerl 2019-12-04 07:50:56 UTC
(In reply to Kai Uwe Broulik from comment #4)
> It is a standard :)
> 
> https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API
> https://w3c.github.io/mediasession/

Great! I'll ping Bandcamp about implementing it.
Comment 6 Kai Uwe Broulik 2019-12-04 07:53:01 UTC
Note that plasma-browser-integration implements the spec for Linux desktop, so a vanilla Firefox or Chrome will not work.

On Android's Chrome it should work out of the box, though. Also, I believe on Windows it gives you global media shortcuts, so using this API is always appreciated and luckily becomes more common with websites as time goes on.