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

[whatwg] HTML Audio Element removal from DOM

From: Charles Pritchard <chuck@jumis.com>
Date: Tue, 17 Jan 2012 21:58:11 -0800
Message-ID: <B5374FFB-0A80-4122-956A-7E7C386E74B2@jumis.com>
The issue I'm having with webkit is with running play() immediately after removeChild. Are you hearing an audible pause when doing so in Opera and FF? I believe there should be no audible pause even though there is an event pause and a loop/queue cycle.

-Charles

On Jan 17, 2012, at 9:54 PM, "Michael A. Puls II" <shadow2531 at gmail.com> wrote:

> On Tue, 17 Jan 2012 16:19:37 -0500, Charles Pritchard <chuck at jumis.com> 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.
> 
> It's the behavior in Firefox and Opera too.
> 
> In both cases below, the audio is paused when removed from the document. When added back it's still paused and when you call play(), it continues playing from where it left off.
> 
> <!DOCTYPE html>
> <html lang="en">
>    <head>
>        <meta charset="utf-8">
>        <title></title>
>        <script>
>            window.addEventListener("DOMContentLoaded", function() {
>                var player = document.createElement("audio");
>                player.controls = true;
>                player.autoplay = true;
>                player.src = "test.oga";
>                document.body.appendChild(player);
>                setTimeout(function() {
>                    document.body.removeChild(player);
>                    setTimeout(function() {
>                        document.body.appendChild(player);
>                        player.play();
>                    }, 3000);
>                }, 7000);
>            }, false);
>        </script>
>    </head>
>    <body>
> 
>    </body>
> </html>
> 
> 
> <!DOCTYPE html>
> <html lang="en">
>    <head>
>        <meta charset="utf-8">
>        <title></title>
>        <script>
>            window.addEventListener("DOMContentLoaded", function() {
>                var player = document.getElementsByTagName("audio")[0];
>                setTimeout(function() {
>                    player = document.body.removeChild(player);
>                    setTimeout(function() {
>                        player = document.body.appendChild(player);
>                        player.play();
>                    }, 3000);
>                }, 7000);
>            }, false);
>        </script>
>    </head>
>    <body>
>        <audio controls autoplay src="test.oga"></audio>
>    </body>
> </html>
> 
> -- 
> Michael
Received on Tuesday, 17 January 2012 21:58:11 UTC

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