Lifetime of new Audio()

I have a question about an audio element created using the constructor. Consider the following function:

function playAudio() {
  var a = new Audio("http://www.example.com/music");
  a.play();
}

Ignoring for now the timing issue of how quickly the play() actually has enough content to start playing, after the function returns there is no reference to the Audio object. Is the fact that the object is playing enough to pin it in memory? Otherwise the GC could collect the object and stop the playing. I scanned the media section of the spec but couldn't see where it defines this behaviour one way or the other.

Any thoughts?

Thanks,

Adrian.

Received on Monday, 31 January 2011 01:53:39 UTC