I am trying to play my music within my game app and it crashes. But when I copy and paste the code within a different xcode
project it works?
I'm using a 2d game engine called SpriteKit
within Xcode
. I play an mp3 file using the AVFoundation framework.
NSURL *url = [[NSBundle mainBundle] URLForResource:@"backgroundMusic" withExtension:@"mp3"];
self.backgroundMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
self.backgroundMusic.numberOfLoops = 1;
[self.backgroundMusic prepareToPlay];
[self.backgroundMusic play];