audio on load

263 views
Skip to first unread message

ealmuno ealmuno

unread,
Sep 4, 2011, 4:27:03 AM9/4/11
to LimeJS HTML5 Game Framework
Hello, i can i start audio when the game is open, if i simply try with

var startaudio = new lime.audio.Audio("path.pm3");
startaudio.play();

not works, if i add to a events it works.

Tõnis

unread,
Sep 5, 2011, 4:32:00 AM9/5/11
to LimeJS HTML5 Game Framework
On some browsers(chomre,firefox I think) you can call
startaudio.isLoaded() to check if the audio is available. Play should
work then.

The reason we haven't implemented it is because there is currently no
way to have it working in iOS/Android and we like to keep the API
consistent.

Pavlo Yuriychuk

unread,
Sep 5, 2011, 4:35:38 AM9/5/11
to lim...@googlegroups.com
For iOs there's a working implementation for sounds http://remysharp.com/2010/12/23/audio-sprites/ . 
But it's better to wait for normal implementation of sound. 

Try to call startaudio.load() befor playing. Some browsers do not start loading by themselves.


Alessio M

unread,
Sep 5, 2011, 2:09:45 PM9/5/11
to LimeJS HTML5 Game Framework
Thanks, i try but not works (i develop on chrome), this is not a big
problem i can implement in "classic" mode.

mghicks

unread,
Sep 12, 2011, 11:46:30 AM9/12/11
to LimeJS HTML5 Game Framework
FWIW (perhaps I misunderstand this thread), I created

* sound.mp3
* sound.ogg

and then added to helloworld.js:

var sound = new lime.audio.Audio('sound.mp3');
goog.events.listen(target,['mousedown','touchstart'],function(e){

if (sound.isLoaded() && !sound.isPlaying()) {
sound.play();
}

e.swallow(['mouseup','touchend'],function(){
if (sound.isPlaying()) {
sound.stop();
}
});
}

And sound worked in both FF (PC) and on my iPhone 3GS. Terribly slow
UI when sound.play is called on iPhone, but correct. iOS 4.2.1
(8C148)

Reply all
Reply to author
Forward
0 new messages