Re: [mediacapture-screen-share] Auto-pause capture when user switches captured content (#255)

> ... it is implied when using [onmessage](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/message_event)"_, which makes this equivalent:
> 
> ```js
> const controller = new CaptureController();
> controller.onswitch = ({stream}) => video.srcObject = stream;
> video.srcObject = await navigator.mediaDevices.getDisplayMedia({controller});
> ```
> 
> I.e. `manualSwitching()` is implicit with `onswitch`.

This seems less than ideal for me. I think it's a footgun for developers. (See also [François' comment](https://github.com/w3c/mediacapture-screen-share/issues/255#issuecomment-1731065156)). But before we do a deep dive on this particular detail...

... I wonder if we should eschew both `onswitch` and `addEventListener` to begin with, because allowing the registration of multiple event listeners seems like a footgun in itself.
* Do the events have...
  * ...multiple tracks?
  * ...clones?
  * ...separate references to the same track?
* What happens if the first event handler stops the tracks, and then the next event is fired with stopped tracks?
* What if the developer enables manual switching and neglects to register an event handler?
* What if the developer registers an event handler and neglects to enable manual switching?

It seems better to shape the API as `enableManualSwitching(handler)`. This ensures exactly one handler, neatly solving all of the these issues.

-- 
GitHub Notification of comment by eladalon1983
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/255#issuecomment-1731190753 using your GitHub account


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

Received on Friday, 22 September 2023 10:32:05 UTC