there is a easier way to add background music to your scene. i use the following steps and works just as good as any other methods and it is easier.
import the @import AVFoundation;
at the top of your scene.
add it as a property right after your @implementation
.
AVAudioPlayer *_backgroundMusicPlayer;
then declare a method for the music
- (void)playBackgroundMusic:(NSString *)filename
{
NSError *error;
NSURL *backgroundMusicURL =
[[NSBundle mainBundle] URLForResource:filename
withExtension:nil];
_backgroundMusicPlayer =
[[AVAudioPlayer alloc]
initWithContentsOfURL:backgroundMusicURL error:&error];
_backgroundMusicPlayer.numberOfLoops = -1;
[_backgroundMusicPlayer prepareToPlay];
[_backgroundMusicPlayer play];
}
after that create a reference to that method in your -(id)initWithSize:(CGSize)size
like the following
[self playBackgroundMusic:@"bgMusic.mp3"];
that should take care of the background music for you.