Вопрос

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");
}
Это было полезно?

Решение

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!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top