W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2007

[whatwg] When to stop <video> elements from playing

From: Maciej Stachowiak <mjs@apple.com>
Date: Fri, 19 Oct 2007 11:40:38 -0700
Message-ID: <39157566-D5AA-4616-8192-E8C57E2B0C8A@apple.com>

On Oct 18, 2007, at 3:28 PM, Robert O'Callahan wrote:

> Suppose a script creates a <video> element, adds it to the document,  
> starts it playing, then removes the element from the document and  
> drops all references to it. When should the element stop playing?
> -- when the element leaves the document? 
> -- when all JS references to the element have been dropped (and  
> garbage collection runs)?
> -- when the user leaves the page?
> -- when the end of the stream is reached? (which could be "never")

I think it would be ok to do a one-time stop of a playing <video> and  
<audio> element at the time it is removed from the document, but still  
allow at least <audio> (and maybe <video> too for consistency, though  
it seems gratuitous) to play play if is outside the document already  
when it starts. In any case, like <img>, I think loading should be  
able to proceed when outside the document or set to display: none.

Stopping at remove time ensures that sounds and videos end at a  
deterministic time when parts of the document are replaced, say with  
innerHTML. Without this, if you replace a piece of the document that  
may contain <video> or <audio> elements you will have to search for  
them first and make sure to stop them. However, if the element can  
still start to play when outside the document, that addresses the use  
case for programmatic audio for things like game sound effects.

Regards,
Maciej
Received on Friday, 19 October 2007 11:40:38 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:37 UTC