Reputation: 345
Hi I'm playing the audio file in one view controller when i going the another view controller its still playing the audio how to pause the audio when we going back to another view controller.
- (void)dealloc {
if ([self.audioPlayer isPlaying])
[self.audioPlayer stop];
[super dealloc];
}
The above code is only works on the navigation view controller if navigate form using the navigation view controller. But i use the normal view controller if i click the back button the audio still plays the audio. This above code is not working on the normal view controller. Please tell how to pause the audio on the normal view controller.
Thanks.
Upvotes: 0
Views: 235
Reputation: 4919
Add your code in ViewWillDisappear
- (void)viewWillDisappear{
if ([self.audioPlayer isPlaying])
[self.audioPlayer stop];
}
Upvotes: 1