[whatwg] HTML Audio Element removal from DOM

Charles Pritchard chuck at jumis.com
Tue Jan 17 21:58:11 PST 2012


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



More information about the whatwg mailing list