createSound stopping code execution
I have a problem with the creation of a Sound. If I turn on the preload option the UI is blocked and the code after Titanium.Media.createSound is not executed until the file is preloaded.
Do I do something wrong or is this a Bug? I don't have this problem if I'm downloading a file. Only when I stream it.
sound = Titanium.Media.createSound({
url:url,,
preload:true,
looping:false
});
alert('Test');
sound.addEventListener('error', function(){
createError('Server not available');
});
sound.play();
Here the alert is called when the file is ready to play. What I want is, that the alert is called immediately after createSound is called.
1 Answer
-
add a complete event to the sound, and inside put the alert.
sound.addEventListener('complete', function(){ alert('Test'); });