Quote:
- (void)viewDidLoad {
NSString *backgroundMusicPath = [[NSBundle mainBundle] pathForResource: @"Background Music" ofType: @"wav"];
NSURL *backgroundMusicURL = [[NSURL alloc] initFileURLWithPath:backgroundMusicPath];
AVAudioPlayer *backgroundMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:backgroundMusicURL error:nil];
[backgroundMusic play];
backgroundMusic.numberOfLoops = -1;
}
|
I think you should keep the reference of the backgroundMusic AVAudioPlayer you initaited in viewDidLoad, and stop the playing of this particular player in the IBAction function