[mediacapture-screen-share-extensions] Auto-pause capture when user switches captured content (#4)

eladalon1983 has just created a new issue for https://github.com/w3c/mediacapture-screen-share-extensions:

== Auto-pause capture when user switches captured content ==
Both Chrome and Safari now allow the user to change what surface is captured.

<p align="center">
   <img src="https://user-images.githubusercontent.com/22117736/208701091-711c8686-5088-43c0-87b4-0117bb6e300d.jpg" alt="I was too lazy for alt-text."/>
<img src="https://user-images.githubusercontent.com/22117736/208702626-80da7ad2-fd72-48b9-bf8c-ba34d9014e4a.png" alt="I was too lazy for alt-text."/>
</p>

That's obviously great stuff. Can we make it better still?
* What if an application intends to do some processing that depends on the captured content?
* What if an application wants to set different constraints, for instance when capturing a window vs. when capturing a screen?
* What if the application intends to save different surfaces to different files, and wants to start appending to a new file whenever the user changes the source?

So I propose that we add **two things**:
1. A control which allows an application to instruct the browser - whenever the user changes what surface is shared, pause the track (by setting [enabled](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/enabled) to false).
2. Fire an event whenever this happens. (With the general expectation that the application will apply new processing and then set `enabled` back to true.)

Possibly the two can be combined, by specifying that setting an event handler signals that the pausing behavior is desired (@alvestrand's idea).

Another natural extension of this idea is to also apply it when a captured tab undergoes cross-origin navigation of the top-level document. When that happens, some applications might wish to stop capture momentarily and (in-content) prompt the user - "do you still want to keep sharing?"

Relevant previous discussion [here](https://github.com/w3c/mediacapture-screen-share/issues/182#issuecomment-855976799).

Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share-extensions/issues/4 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 23 February 2024 08:50:23 UTC