I have an audio file that plays when a user clicks on one view. my problem is that if they move to another view the audio continues to play. I would like the audio to stop if the user is no longer on that view.
is this done in the viewDidUnload method?
here's the code that plays the audio after a 15sec delay:
-(void)startPlaying {
[NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(startPlaying) userInfo:nil repeats:NO];
NSString *audioSoundPath = [[ NSBundle mainBundle] pathForResource:@"audio_file" ofType:@"caf"];
CFURLRef audioURL = (CFURLRef) [NSURL fileURLWithPath:audioSoundPath];
AudioServicesCreateSystemSoundID(audioURL, &audioID);
AudioServicesPlaySystemSound(audioID);
}
thanks for any help.