Stop and Resume audio from other view controller iOS AVPlayer

I have an app that plays sound when it loads. This happens in the AppDelegate.m file because the audio is used in most places. But I would like to pause the sound when the user clicks on the help menu because the help menu contains a help video and I do not want the sound to interfere. And when the user goes back to the main menu I want the sound to resume. Basically I would like to access the sound and perform things on it. How can I do this.

Thanks in advance!


AppDelegate.m:

- (void)applicationDidBecomeActive:(UIApplication *)application

{

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/AppMusic.mp3", [[NSBundle mainBundle] resourcePath]]];


NSError *error;

audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];

audioPlayer.numberOfLoops = INFINITY;


[audioPlayer play];

}

OS X Mountain Lion (10.8.2)

Posted on Mar 27, 2013 1:00 AM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Stop and Resume audio from other view controller iOS AVPlayer

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.