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

> I'd still like to see an example of an application that benefits of this possibility.

In [today's meeting](https://docs.google.com/presentation/d/1JNs-s02_bv8tz0wVpKB_Uczq91qfG6pTNasBxabEmv0/edit#slide=id.g2a5d4ac53e0_6_20) the early decision example shown was:
```js
getDisplayMedia({appAssistedSurfaceSwitching: "include", …})
controller.onsourceswitch = event => {
  video.srcObject = event.stream;
};
```
But this will [glitch](https://jsfiddle.net/jib1/7L4wg5dt/) in all browsers, even for same-type switching, because it reruns the [media element load algorithm](https://html.spec.whatwg.org/#media-element-load-algorithm).

A late decision seems inherently needed to fix this glitch for the subset of same-type switching. E.g.
```js
controller.onsourceswitch = ({stream}) => {
  if (!compatibleTypes(video.srcObject, stream)) {
    event.preventDefault(); // Use switch-track model
    video.srcObject = stream;
  }
};
```
Glitching may similarly happen with other sinks, like MediaRecorder or WebAudio.


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


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

Received on Tuesday, 12 December 2023 19:29:29 UTC