HTML 5 video promise problems
Reported by
m...@mimo-design.com,
Oct 31 2016
|
||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36 Steps to reproduce the problem: 1. Run this example http://codepen.io/mimse/pen/zKVbQK 2. Click play in both examples What is the expected behavior? Play promise should be rejected in both cases because the src is invalid. What went wrong? If source is used, the promise will stay pending and never be rejected Did this work before? No Does this work in other browsers? Yes Chrome version: 54.0.2840.71 Channel: stable OS Version: OS X 10.12.1 Flash Version: Shockwave Flash 23.0 r0
,
Oct 31 2016
,
Nov 3 2016
Thanks for the report. You will notice that the second video have a null `error` property which probably explains why the promise was not rejected. I'm not super familiar to this part of the specification but I can't find a place where the specification says that when no valid <source> was found, it should fail the same way it does for the src attribute. My understanding is that the media element is expected to wait until a new candidate shows up. foolip@, any feedback?
,
Nov 3 2016
That an invalid <source> doesn't reject the promise is per spec, and unfortunately it'd be hard to make it any different. https://html.spec.whatwg.org/multipage/embedded-content.html#concept-media-load-algorithm defines how to pick a source, and in this case we'd end up at "Wait until the node after pointer is a node other than the end of the list. (This step might wait forever.)" The problem is that with <source> elements, another source can be inserted at any future time and should be picked up, so we are indefinitely waiting and may eventually actually play if a source is added.
,
Nov 3 2016
So either use <source> to be a good web citizen with multiple sources, or get a rejected promise whenever play() fails? That makes no sense. :|
,
Nov 3 2016
The play() promise is supposed to reject when play fails. The problem is that when using <source>, we never really fail to play, we're just waiting around for another <source> to be inserted. It doesn't make any sense if you don't know the "resource selection algorithm" in detail, but I also don't know how to fix it. Suggestions welcome at https://github.com/whatwg/html/issues/new
,
Nov 3 2016
From the perspective of a web developer, it makes no sense. You put <source> and then you play(). Why would I do anything else? If I did it backwards, yes, play() should fail and not play. I bet backwards compatibility will suffer if you switch to it, huh? I think this behavior is a mistake. The autoplay scenario might make sense, but play()? No.
,
Nov 3 2016
Again, suggestions welcome at https://github.com/whatwg/html/issues/new. What would be needed is a well defined point in time when you decide that no more <source> elements are coming after all, at which point you could switch paused back to true and reject pending play promises. The tricky bit is what that timing should be.
,
Nov 3 2016
But did the non-promise based play() start playing as soon as new <source> has been appended (say, five seconds after it exhausted all of its current <source> children?)? If so, it will probably not be web compatible to change this (quantifiable, obviously).
,
Nov 3 2016
Yes, this has been the interaction of play() and <source> since very early on: https://github.com/whatwg/html/commit/a8fa711afc07b1153cbc196074f9573bb741c0c7 Somewhat simplified, play() just sets the paused attribute to false, which means that one is trying to play. Combined with <source>, one could be "trying" forever.
,
Nov 4 2016
I'm afraid I will have to mark this as WontFix and suggest that a spec issue is filed otherwise.
,
Nov 4 2016
Thank you for looking into the issue. What bothers me the most is that src attribute and source elements make the video element behave differently. |
||||
►
Sign in to add a comment |
||||
Comment 1 by phistuck@chromium.org
, Oct 31 2016Status: Untriaged (was: Unconfirmed)