Last active
December 19, 2015 03:48
-
-
Save rblalock/5892327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var snd = new Audio( mySoundFile ); | |
snd.load(); | |
snd.play(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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