I'm looking to stop an audio file from playing when the view is changed.
I'm using a tabController and I would like the audio that's playing to stop when the user moves to a different view. I'm not sure where and how I would do this. in the viewDidUnload perhaps?
here's the method I'm using to play the audio file:
-(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