I also support this request and I think it should be in the browser for security reasons. As a general rule I don't think websites should be able to alter the functionality of applications on the system without explicit control from the browser. In this case websites are able to intercept the hardware media playback keys that are otherwise going to iTunes or other system applications.
What I would like to see is a UI preference for controlling Hardware Media Keys controls: Disabled, Enabled, and Enabled for Select Websites (e.g. one could specify just Spotify can take over the hardware media keys thus excluding other websites such as Youtube and WSJ from intercepting those keys).
I would also like to see a similar thing for system/browser keyboard shortcuts but will request that separately. As a preview of this issue, some websites like TikTok are able to redirect browser keyboard shortcuts like Command-L and Command-N which I think could have security implications. It is routine for advanced applications (e.g. Google Sheets) to grab some keyboard shortcuts but I think shortcuts that are used by the browser (system, etc) should be off limits (and that limit should be enforced by the browser).
In any case while Safari and Orion+ seem to handle this the same currently I don't think this is actually handled by WebKit. My guess is that Apple's system library routines are just passing through all events unless intercepted so Safari and Orion+ end up with the same behavior. If it helps, below is how Chromium intercepts media key events to process and otherwise lets other events pass through:
// Convert the CGEvent to an NSEvent for access to the data1 field.
NSEvent* ns_event = [NSEvent eventWithCGEvent:event];
if (ns_event == nil) {
return event;
}
// Ignore events that are not system defined media keys.
if (type != NX_SYSDEFINED
[ns_event type] != NSSystemDefined
[ns_event subtype] != kSystemDefinedEventMediaKeysSubtype) {
return event;
}
NSInteger data1 = [ns_event data1];
// Ignore media keys that aren't previous, next and play/pause.
// Magical constants are from http://weblog.rogueamoeba.com/2007/09/29/
int key_code = (data1 & 0xFFFF0000) >> 16;
if (key_code != NX_KEYTYPE_PLAY && key_code != NX_KEYTYPE_NEXT &&
key_code != NX_KEYTYPE_PREVIOUS && key_code != NX_KEYTYPE_FAST &&
key_code != NX_KEYTYPE_REWIND) {
return event;
}