Skip to content

Instantly share code, notes, and snippets.

@rblalock
Last active December 19, 2015 03:48
Show Gist options
  • Save rblalock/5892327 to your computer and use it in GitHub Desktop.
Save rblalock/5892327 to your computer and use it in GitHub Desktop.
Ti.App.addEventListener("playSound", function(_event) {
var soundPlayer = Ti.Media.createSound({
url: "/game/" + _event.soundFile
});
soundPlayer.play();
soundPlayer.addEventListener("complete", function() {
if(OS_ANDROID) {
soundPlayer.release();
}
});
});
var snd = new Audio( mySoundFile );
snd.load();
snd.play();
playSound: function(_soundFilePath) {
if(Globals.GAMETYPE === "titanium") {
Ti.App.fireEvent("playSound", {
soundFile: _soundFilePath
});
} else {
var snd = new Audio( _soundFilePath );
snd.load();
snd.play();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment