On 1/17/12 1:38 PM, Eric Carlson wrote:
On Jan 17, 2012, at 1:32 PM, Andrew Scherkus wrote:

On Tue, Jan 17, 2012 at 1:19 PM, Charles Pritchard<[email protected]>  wrote:

When an<audio>  element is removed from the DOM while playing, is that
element paused?
That seems to be the behavior in Chrome. I'm looking for clarification.

I was able to repro this in both Safari 5.1.1 and Chrome 17.0.963.26 dev so
perhaps it's a bug in WebKit as the spec states the following:
"""
Media elements that are potentially playing while not in a Document must
not play any video, but should play any audio component. Media elements
must not stop playing just because all references to them have been
removed; only once a media element is in a state where no further audio
could ever be played by that element may the element be garbage collected.
"""

   That is for an element that is playing when it is not in the document. Look 
at the end of 
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#playing-the-media-resource
 for the definition of what to do when an element is removed from the DOM:

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.
};

-Charles

Reply via email to