Open Bug 1872636 Opened 9 months ago Updated 9 months ago

Give extensions access to MediaSession of a tab

Categories

(WebExtensions :: General, enhancement, P5)

enhancement

Tracking

(Not tracked)

People

(Reporter: gregp, Unassigned)

References

Details

(Whiteboard: [wecg])

I've been prototyping a browser extension that adds play/pause buttons to the tab context menu. A problem I've run into is that there's no good way to interact with the page's MediaSession from the background page. Currently, I've worked around this by using a content script and passing messages back and forth. This is not good for performance and requires the scary 'Access your data for all websites' permission.

Something like tab.mediaSession should be added which gives extensions easy access to play/pause and maybe MediaMetadata.

There's already a ChromeOnly MediaController thing that seems to do exactly this, which could be used to add this capability to extensions.

I'm not familiar with how web extension works, but I would suggest expose MediaController to web extension instead of exposingf the media session. The reason is a page can contain multiple media session, or not media session at all (simply playing media without using media session API). Media controller can handle all those situations and knows which media session should be controlled for the multiple media sessions case.

If we want to do something here, we'd probably want to align with other vendors, and Chromium folks especially might have opinions, they've been doing lots of stuff in this area, both for the web and for extensions IIRC.

Could you file an issue with use cases in the WECG repo please: https://github.com/w3c/webextensions/

Whiteboard: [wecg]
Flags: needinfo?(gregp)
Flags: needinfo?(gregp)
Severity: -- → N/A
Priority: -- → P5
You need to log in before you can comment on or make changes to this bug.