Ejecta icon indicating copy to clipboard operation
Ejecta copied to clipboard

preload sound / audio on start ?

Open matrixreal opened this issue 10 years ago • 9 comments
trafficstars

hi, is there a way to preload / load all sound of game lunch ? thanks in advance

matrixreal avatar Apr 22 '15 02:04 matrixreal

load every sound one by one .

finscn avatar Apr 22 '15 02:04 finscn

and how to do it ? what is the call ?

matrixreal avatar Apr 22 '15 02:04 matrixreal

this is not a function of Ejecta and My fork. I think it like you load images

var audio=new Audio()
audio.src=url
audio.addEventListener("canplaythrough", function(){....});
audio.addEventListener("error", function(){....});

finscn avatar Apr 22 '15 03:04 finscn

it work for local audio ? i mean that i want to preload sound on the game like the images (load into memory to avoid memory leak or game freez)

matrixreal avatar Apr 22 '15 03:04 matrixreal

yes , could work for local audio

finscn avatar Apr 22 '15 04:04 finscn

and we have to replace url by "media/sound.m4a" ?

matrixreal avatar Apr 22 '15 04:04 matrixreal

yes

finscn avatar Apr 22 '15 05:04 finscn

@finscn please , whats the javascript call to set sound to mute or silent ? thanks

matrixreal avatar Apr 28 '15 12:04 matrixreal

audio.muted = true or audio.volume = 0

there is no way to let all audios be muted, you have to set that one by one .

finscn avatar Apr 29 '15 07:04 finscn