[whatwg] When to stop <video> elements from playing
Jonas Sicking
jonas at sicking.cc
Tue Oct 23 17:56:29 PDT 2007
Robert O'Callahan wrote:
> After some discussion on IRC, I think Jonas, Hixie and I agreed that
> we're OK with the following approach:
> -- sound is produced for display:none elements and elements not in the DOM
> -- removing an element from the DOM automatically calls stop() on that
> element
> -- tearing down the owner document always stops the element playing (so
> navigating away from the page always stops sound)
>
> Therefore
> myAudio = new Audio("foo.wav");
> myAudio.onload = function () {
> this.play();
> myAudio = null;
> }
> will work, and will play until the sound ends or the user leaves the page.
One thing that I was thinking of that might be beneficial both for the
greasemonkey case, and for debugging purposes is to have an API where
you can enumerate all currently sounding audio/video elements. This
could something like:
interface Document {
...
readonly NodeList soundingMediaElements;
...
}
The UA would most likely have to keep a list like this anyway in order
to protect these elements from getting garbage collected.
One argument against this is that it might make it harder for
implementations to optimize what elements it's keeping alive. For
example, an implementation could remove an element from this list if it
knows that a <video> contains no audio from the current play position to
the end, even if earlier parts did contain audio.
/ Jonas
More information about the whatwg
mailing list