Closed ekelokorpi closed 10 years ago
How about using https://github.com/goldfire/howler.js/ ?
Hmm, I really want use external libraries as little as possible, just to keep control of how everything works.
And i'm almost done rewriting the module :)
Though Howler features look pretty nice :+1:
First version ready: https://github.com/ekelokorpi/panda.js/blob/develop/src/engine/audio.js
Syntax:
// Add audio to loader
game.addAudio('media/jump.m4a', 'jump');
// Play audio as a sound
game.audio.playSound('jump');
// Define volume
game.audio.playSound('jump', 1.0);
// Loop sound
game.audio.playSound('jump', 1.0, true);
// Define callback
game.audio.playSound('jump', 1.0, true, function() {
console.log('Audio played');
});
// Define playback rate (only in Web Audio)
game.audio.playSound('jump', 1.0, false, false, 0.5);
Lots of room for optimization, cleaner code, better syntax.