W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2012

[whatwg] HTML Audio Element removal from DOM

From: Simon Pieters <simonp@opera.com>
Date: Wed, 18 Jan 2012 10:01:21 +0100
Message-ID: <op.v79vcjuhidj3kv@simon-pieterss-macbook.local>
On Tue, 17 Jan 2012 23:44:58 +0100, Charles Pritchard <chuck at jumis.com>  
wrote:

>> When a media element is removed from a Document, the user agent must  
>> run the following steps:
>> 	1. Asynchronously await a stable state, allowing the task that removed  
>> the media element from the
>> 		Document to continue. The synchronous section consists of all the  
>> remaining steps of this algorithm.
>> 		(Steps in the synchronous section are marked with.)
>> 	2. If the media element is in a Document, abort these steps.
>> 	3. If the media element's networkState attribute has the value  
>> NETWORK_EMPTY, abort these steps.
>> 	4. Pause the media element.
>
> This seems to reflect the current webkit behavior. The element is paused  
> when it's removed from the Document.
> I'll focus on the bug report I'm putting together.
> function example() {
> var a = audioElement.parentNode.removeChild(audioElement);
> a.play(); // there is an audible pause.
> };

This, per spec, should cause the element to be paused. See step 1 above.  
a.play() will run before the algorithm reaches step 4. Currently you would  
need to wait for the "paused" event and play() from there. We could change  
the spec so that play() sets a flag on the element that the algorithm  
above checks before pausing the element, or some such, to make the above  
do the intended.

-- 
Simon Pieters
Opera Software
Received on Wednesday, 18 January 2012 01:01:21 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:10 UTC