w3c / mediasession

Media Session API
https://w3c.github.io/mediasession/
Other
127 stars 29 forks source link

Telephony use cases #199

Open reillyeon opened 6 years ago

reillyeon commented 6 years ago

In addition to supporting media playback and access to the media action keys present on many platforms the MediaSession API also seems to fit the bill for telephony use cases such as notifying the user of an incoming or active call and providing on/off hook and volume controls.

thexeos commented 6 years ago

This can definitely be a use case for MediaSession API. Right now, it can be tricky to let the person know about the incoming call. If no sound has been played from the tab, and the tab is in the background (and on mobile, if no user gesture was present), there is no way to sound the ringtone. The only way to notify of the call is to use the Notifications API.

Problems with Notifications API approach are: 1) No way to play the sound together with the notification (and sound from the tab may be desynchronized with the notification) 2) Limited control over how the action buttons look. On some platform the buttons are stacked (one per row) and on others they are displayed two per row. 3) No direct contact with the page - the action button clicks are handled in the Service Worker, which then has to pass the data to the tab that requested the notification (or in case it was triggered by Web Push API, then the page has to be opened first, then the page has to request the data from the service worker, since there is no way that I know of, which would allow notificationclick event handler to reliably stay running while the page is being loaded, and then pass the newly loaded page the click data)

Having MediaSession API provide built-in functions would definitely help.

For the call initiation:

And during the call:

And after the call:

There are a lot of things to discuss, especially the complex use-cases. For example, what if the person receives multiple calls at once, or what if the app supports conference calls, and another participant is added to the call? Would there be a "hold" mode, where one call is left hanging, while the other call is active? What about "mute" buttons, is it a responsibility of MediaSession API? What about when both audio and video streams are present? Should they both be toggleable from the "notification"?

youennf commented 1 year ago

Marking as enhancement. Some related API about camera/microphone have been added, is it enough?

tomayac commented 1 year ago

Also see Edge's extensions to the Notifications API actions.