开发者

Throw away sound effects in Javascript using HTML5 audio?

开发者 https://www.devze.com 2023-01-14 12:09 出处:网络
I\'m building a simple game using a canvas tag and want to add some sound effects to it. If I use the following code to play the SFX...

I'm building a simple game using a canvas tag and want to add some sound effects to it. If I use the following code to play the SFX...

function playSfx( sound ) {
 var snd = new Audio("file.mp3");
 snd.play();
}

Is the garbage collection / memory management clever enough to play the sound and then dispose of the Audio object? Or will I have to keep track of the object and destroy it开发者_C百科 when it has finished playing?

0

精彩评论

暂无评论...
验证码 换一张
取 消