Frage

so I have the code shown but my music is not playing and I'm not sure why. the sound on my computer is turned up xcode can play the file that i imported in.

-(void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    NSError *error;
    NSLog(@"starting Music");
    NSURL * backgroundMusicURL = [[NSBundle mainBundle] URLForResource:@"rainbowRoad" withExtension:@"m4a"];
    self.backgroundMusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:backgroundMusicURL error:&error];
    self.backgroundMusicPlayer.numberOfLoops = -1;
    [self.backgroundMusicPlayer prepareToPlay];
    [self.backgroundMusicPlayer play];
    NSLog(@"awesome");
}
War es hilfreich?

Lösung

I don't think your sound file is being copied. Select your audio file in Xcode, then in the File Inspector's Target Membership section, make sure your target is checked.

Check this thing!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top