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

Jonas Sicking jonas at sicking.cc
Fri Oct 19 17:38:02 PDT 2007


James Cox wrote:
> 
> On 20 Oct 2007, at 00:31, 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
> 
> what about people hiding ads or other elements via greasemonkey scripts 
> (and so on) - using display:none hacks to remove from visibility? If 
> naming is an issue, how about a new css element of active:none; which 
> prevents any video/sound/display playing.

The greasemonkey script could easily find all audio/video elements and 
stop them.

>> -- 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.
> 
> Is there still a way to find this element in the DOM? Again, thinking 
> about greasemonkey scripts which want to kill all sound in a page.

No, there is no way to find these elements. Ideal is if UAs expose some 
internal API that extensions can use to mute the sound on the page.

/ Jonas



More information about the whatwg mailing list