[mediacapture-main] Clarification needed on HTMLMediaElement with MediaStream ending playback

Pehrsons has just created a new issue for https://github.com/w3c/mediacapture-main:

== Clarification needed on HTMLMediaElement with MediaStream ending playback ==
Spec says this on ending media elements:
> When the MediaStream state moves from the active to the inactive state, the User Agent MUST raise an ended event on the HTMLMediaElement and set its ended attribute to true.

This seems too simple as an HTMLMediaElement whose source reaches the end goes through [a lot more steps](https://html.spec.whatwg.org/multipage/media.html#reaches-the-end):

> When the current playback position reaches the end of the media resource when the direction of playback is forwards, then the user agent must follow these steps:
> 
> 1. If the media element has a loop attribute specified, then seek to the earliest possible position of the media resource and return.
> 2. As defined above, the ended IDL attribute starts returning true once the event loop returns to step 1.
> 3. Queue a task to run these steps:
>     1. Fire an event named timeupdate at the media element.
>     2. If the media element has ended playback, the direction of playback is forwards, and paused is false, then:
>         1. Set the paused attribute to true.
>         2. Fire an event named pause at the media element.
>         3. Take pending play promises and reject pending play promises with the result and an "AbortError" DOMException.
>     3. Fire an event named ended at the media element.

It seems preferable to me to refer to this algorithm instead of rolling our own.

Note that the HTMLMediaElement spec also lists [the conditions](https://html.spec.whatwg.org/multipage/media.html#ended-playback) for when a media element is said to have ended playback:

> A media element is said to have ended playback when:
> - The element's readyState attribute is HAVE_METADATA or greater, and
> - Either:
>   - The current playback position is the end of the media resource, and
>   - The direction of playback is forwards, and
>   - The media element does not have a loop attribute specified. 
> - Or:
>   - The current playback position is the earliest possible position, and
>   - The direction of playback is backwards. 
> 
> The ended attribute must return true if, the last time the event loop reached step 1, the media element had ended playback and the direction of playback was forwards, and false otherwise.

It seems to me that if we override the condition for when the media element has ended playback to support MediaStreams, we'd get the algorithm with events and state for free.

Please view or discuss this issue at https://github.com/w3c/mediacapture-main/issues/518 using your GitHub account

Received on Friday, 25 May 2018 09:01:32 UTC