Created
August 18, 2010 18:24
-
-
Save dmnkhhn/535709 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
// this little snippet demonstrates how you can handle multiple sounds with just one play button | |
// switch through the sounds with a simple scroll gesture (by using a ScrollableView | |
// this code is not complete!! Use it on your own risk. :-) | |
function createSound(url) { | |
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, url); | |
return Titanium.Media.createSound({sound:file}); | |
}; | |
// called once, loading the first sound to play | |
var sound = createSound('myfile.mp3'); | |
// var scrollView = Titanium.UI.createScrollableView({}); | |
scrollView.addEventListener('scroll', function(e) { | |
var page = e.currentPage; | |
sound = createSound(soundfiles[page][0].file); | |
}); | |
// var play = Titanium.UI.createButton({}).... | |
play.addEventListener('click', function() | |
{ | |
sound.play(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment