[whatwg] Why does CanvasRenderingContext2D.drawImage not draw a video's poster?

Silvia Pfeiffer silviapfeiffer1 at gmail.com
Sat Jul 21 13:20:09 PDT 2012


On Thu, Jul 19, 2012 at 2:46 AM, Charles Pritchard <chuck at jumis.com> wrote:
> On 7/17/2012 11:06 PM, Silvia Pfeiffer wrote:
>>
>> On Wed, Jul 18, 2012 at 6:57 AM, Charles Pritchard <chuck at jumis.com>
>> wrote:
>>>
>>> On Jul 17, 2012, at 9:04 PM, Mark Callow <callow_mark at hicorp.co.jp>
>>> wrote:
>>>
>>>> On 18/07/2012 00:17, Silvia Pfeiffer wrote:
>>>>>
>>>>> I think this is simply an idea that hasn't been raised before. I like
>>>>> it. Though even then sometimes there may be nothing when there is no
>>>>> explicit poster and preload is set to none.
>>>>
>>>> The language gives me the impression that drawing nothing was a
>>>> deliberate choice, in particular because later on it says:
>>>
>>>
>>> We don't have events based on poster, so we don't know whether or not
>>> it's been loaded. Poster is meant for the video implementation. We use other
>>> events to know if video is playing.
>>>
>>> So as a coder, I can just do an attribute check to see if poster exists,
>>> then load it into an image tag. It's a normal part of working with Canvas.
>>> We always follow onload events.
>>
>> IIUC, that still excludes the case where there is no @poster attribute
>> set on video, @autoplay is set to none, and the browsers load the
>> first frame as the poster. It would make sense in this case to hand
>> that poster to the canvas. And it would make it easier if the
>> explicitly set @poster attribute would be used, too, so you don't have
>> to do that by hand.
>
>
> We need more data if we're going to try that, and I'm still rather timid on
> the idea though it would be nice if <img> would load the first frame of
> video (and ".gif" for that matter).
>
> We really don't know what the browser is going to show if it's not showing a
> poster. It could show an arbitrary frame, it could show some kind of frame
> with a blur or opacity change, it could add on various controls.

This is all theoretical. In practice, all browsers show a black frame,
since no other frame is actually available.


> I'm not opposed to the idea, but I'm failing to see the benefit.

The advantage clearly is that if you have a canvas that is copying
data out of the video, it includes the poster without having to write
custom code for it. The poster is an integral part of the video (it's
not distinguishable by the user whether it is a separate picture or a
frame from the video), so I don't see why it should need custom
handling.

> Still, if
> there's going to be one, we're going to need an onposterloaded event.

Why? onmetadataloaded provides a sufficiently stable stuation: either
the poster img or video frame is then loaded (if @preload is not
"none") or it's black (if @poster is not set and @preload is "none").

I don't follow the objections.

Cheers,
Silvia.



More information about the whatwg mailing list