[whatwg] When to stop <video> elements from playing
ggaren at apple.com
Thu Oct 18 15:55:22 PDT 2007
> 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?
Probably. Since you can't see the video any more, it would be really
weird to hear audio from it, or waste computer resources on a mute and
invisible video. Moreover, there's a lot of precedent for DOM elements
not loading when they're not in the document. This is true of iframe,
script, img, etc.
> -- when all JS references to the element have been dropped (and
> garbage collection runs)?
No. The time at which garbage collection will reclaim an object is
unpredictable, so relying on garbage collection for behavior is a bad
> -- when the user leaves the page?
Certainly. But you might want to stop the video sooner.
> -- when the end of the stream is reached? (which could be "never")
Certainly. (How can you play past the end of the stream?) But you
might want to stop the video sooner.
More information about the whatwg