I'm looking to execute some code after a sound has finished playing but don't know what the best way to do it is. I've looked at performSelectorOnMainThread....
but don't fully understand it - even then, i'm not sure if that's the best way to approach the problem. I want to change the text color of a label after my sound has finished playing. I'd appreciate some help. My code is below:
-(void) playWordSound:(UILabel *)label
{
NSString *path;
SystemSoundID soundId;
switch (label.tag)
{
case 1:
path = [[NSBundle mainBundle] pathForResource:@"humpty" ofType:@"wav"];
break;
case 2:
path = [[NSBundle mainBundle] pathForResource:@"dumpty" ofType:@"wav"];
break;
case 3:
path = [[NSBundle mainBundle] pathForResource:@"saty" ofType:@"wav"];
break;
case 4:
path = [[NSBundle mainBundle] pathForResource:@"on 2" ofType:@"wav"];
break;
case 5:
path = [[NSBundle mainBundle] pathForResource:@"a 3" ofType:@"wav"];
break;
case 6:
path = [[NSBundle mainBundle] pathForResource:@"wall" ofType:@"wav"];
break;
}
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID( (CFURLRef)objc_unretainedPointer(url), &soundId);
AudioServicesPlaySystemSound(soundId);
//this is where i want to change the color of the label
}