I'm trying to figure out how to stop an audio file from playing if the user changes views.
I've found out that the code goes in the viewWillDisappear method, can anyone help w/ the code?
-(void)viewWillDisappear
BOOL)animated {
[super viewWillDisappear:animated];
}
my code to play the audio, after a 10sec delay:
-(void)startPlaying {
[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(startPlaying) userInfo:nil repeats:NO];
NSString *audioSoundPath = [[ NSBundle mainBundle] pathForResource:@"affs" ofType:@"caf"];
CFURLRef audioURL = (CFURLRef) [NSURL fileURLWithPath:audioSoundPath];
AudioServicesCreateSystemSoundID(audioURL, &audioID);
AudioServicesPlaySystemSound(audioID);
}
thanks for any help.