How can I start and stop music in a different nib when the sound file was loaded and starts playing in another nib?
Menu.h Code
Menu.m Code
The class I want to control it from is options. How do I do this?
Menu.h Code
Code:
#import <AVFoundation/AVFoundation.h>
@interface Menu : UIViewController {
AVAudioPlayer* backgroundMusic;
}
Menu.m Code
Code:
- (void)viewDidLoad {
NSString *pathToMusicFile = [[NSBundle mainBundle] pathForResource:@"background" ofType:@"mp3"];
backgroundMusic = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile] error:NULL];
backgroundMusic.numberOfLoops = -1;
backgroundMusic.volume = 0.2;
[backgroundMusic play];
[super viewDidLoad];
}
The class I want to control it from is options. How do I do this?