This was working properly in 1.7.5 but now plays twice in a row.
I have dynamically generated imageviews with a click event that calls a function that creates a sound that plays the sound and releases on complete.
Code as follows:
function pickSound() { var toss = Math.ceil(Math.random() * 12); if(toss < 10) { toss = "0" + toss; } var sound= Titanium.Media.createSound({ url : 'sound/sound' + toss + '.ogg' }); sound.looping = false; var played= zombieDies.addEventListener('complete', function(e) { sound.removeEventListener('complete', played) sound.stop(); sound.release(); }); sound.play(); } imageview.addEventListener('click',function(){pickSound()});It is the only effect that is played twice and it is not consistently played twice.
2 Answers
It's not a solution or answer, but to work around the issue I decided to try using an audioplayer instead of a sound. It works very well, with the mp3s (haven't tested with oggs) and remains dynamic.
There doesn't seem to be any way of cleaning up after (i'm thinking of release) so i'm assuming once the function runs out, the audioplayer will be cleaned out or forgotten? Hence memory isn't an issue?
I hope this helps someone.
Okay, the audioplayer actually doesn't work consistently as I intially expected. So I've redacted all that nice elegant code, and put in a 12 case switch. Yeesh.
Your Answer
Think you can help? Login to answer this question!