The Media Session API standard evolves quite fast, so there's new actions that we might be able to support that the browser itself doesn't know yet, for instance the "stop" action.
By registering the callback to ourselves before calling into the browser, we're still able to handle it in the extension even if not supported by the browser.
Details
Details
- Reviewers
fvogt - Group Reviewers
Plasma - Commits
- R856:a181a9e5b3e8: Handle media session callbacks before passing it on to the browser
The following now works:
navigator.mediaSession.setActionHandler("stop", () => { console.log("stop player"); });
Clicked Stop in context menu of media controller applet, got the callback executed.
Previously an exception would be thrown when calling setActionHandler
Diff Detail
Diff Detail
- Repository
- R856 Plasma Browser Integration
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
extension/content-script.js | ||
---|---|---|
687 | Why add this check and not just save the exception thrown from oldSetActionHandler for throwing later? Otherwise the addon controls which browser functionality is accessible. |