finscn / Ejecta

A Fast, Open Source JavaScript, Canvas & Audio Implementation for iOS
42 stars 6 forks source link

preload sound / audio on start ? #4

Open matrixreal opened 9 years ago

matrixreal commented 9 years ago

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

finscn commented 9 years ago

load every sound one by one .

matrixreal commented 9 years ago

and how to do it ? what is the call ?

finscn commented 9 years ago

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(){....});
matrixreal commented 9 years ago

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)

finscn commented 9 years ago

yes , could work for local audio

matrixreal commented 9 years ago

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

finscn commented 9 years ago

yes

matrixreal commented 9 years ago

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

finscn commented 9 years ago

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 .