Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (complete)
Viewing all articles
Browse latest Browse all 20

sound release kills eventListener

$
0
0

Hi, i have a program that will play 12 different local sound files trough the program. The ending of each sound will trigger a following function. To do this I use Titanium.Media.createSound(); since it's local files. I have a eventListener for complete aadded to sound object. Then I just update the url for sound object for playing next sound. The problem is that for the sound object to really update to the new sondfile I had to add a release function wich led to complete lister to stop work and I get stucked at the second sound. Does this make any sense and do someone know what to do?

Some code(I cut out the parts thats involving sound):

var sound = Titanium.Media.createSound();
sound.addEventListener('complete',soundcomplete);
 
function soundcomplete(){
    sound.release();
    afterSound();
}
 
function afterSound(){
    // lots of functionality that dosn't have anything to do with the sound
}
 
// -- this is the function that will call a new sound
function foundObject(){
    if(oldType=="Fraga"){
        sound.url=arrFragor[nextCount].snd;
        sound.play();       
    }
    else{
        afterSound();
    }
}
So.. afterSound just get called after the first time, if I remove sound.release(); and add a stop the complete listener will work but it dosn't play a new sound instead it just keeps playing the first sound file everytime. Hope someone know anything about this

Best regards! /magnus


Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>