Re: [mediacapture-main] Clarification needed on HTMLMediaElement attributes that carry over (#599)

> So here's my brief test with https://jsfiddle.net/jib1/avr1w8k0/ basically:
> 
> ```
>     video.onratechange = () => console.log("ratechange");
>     video.playbackRate = 0.5;
>     console.log(video.playbackRate);
>     video.srcObject = await navigator.mediaDevices.getUserMedia({video: true});
>     console.log(video.playbackRate);
>     video.playbackRate = 0.7;
>     console.log(video.playbackRate);
>     video.srcObject = null;
>     console.log(video.playbackRate);
> ```
> 
> The results show variance and that none are to spec. They all fire ratechange when they shouldn't, and none of them preserve the non-stream value.
> 
> Firefox:
> 
> ```
> 0.5
> ratechange
> 1
> 0.7
> 1
> ratechange
> ```
> 
> Chrome:
> 
> ```
> 0.5
> ratechange
> 1
> 1
> 1
> ratechange
> ```
> 
> Safari:
> 
> ```
> 0.5
> ratechange
> 1
> 0.7
> 1
> ratechange
> ```
> 
> Edge:
> 
> ```
> 0.5
> ratechange
> 1
> InvalidStateError
> ```
> 
> From my reading of the spec, clarified by #600 it should be:
> 
> ```
> 0.5
> 1
> 1
> 0.5
> ```
> 
> Is there one we prefer? @youennf @Pehrsons

You're fooling yourself, because the [media element load algorithm](https://html.spec.whatwg.org/multipage/media.html#media-element-load-algorithm) contains this:
> 7. Set the playbackRate attribute to the value of the defaultPlaybackRate attribute.

My initial example is equally bad.

Setting both `defaultPlaybackRate` and `playbackRate` will give a better view of the current state.

That said, this example's tracking of "ratechange" provides insight into the corner case where `playbackRate` gets set to `defaultPlaybackRate` after having just set `srcObject` to a `MediaStream`. Should that update of `playbackRate` dispatch a "ratechange"? Not per the above (well, before the fiddle anyway).

-- 
GitHub Notification of comment by Pehrsons
Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/599#issuecomment-497629641 using your GitHub account

Received on Friday, 31 May 2019 08:45:29 UTC