AVAudioPlayer causing simulator crash

Discussion in 'Public Game Developers Forum' started by NickFalk, Jul 13, 2009.

  1. NickFalk

    NickFalk Well-Known Member

    #1 NickFalk, Jul 13, 2009
    Last edited: Jul 13, 2009
    I posted this over at Apple's dev.forums last night, but perhaps someone here can help?

    I have hacked together the following code to play an aac I've created in Garageband

    Code:
    // Creates the bundle "bundle" and fills it with the address of the mainBundle
         NSBundle *bundle = [NSBundle mainBundle];
    // Gets the path for the mainSong
         NSString *path = [bundle pathForResource:@"mainSong" ofType:@"m4a"];
    
    // Checks if the path exists
         if (path != nil){
    // Creates an URL with the path defined above
              NSURL *url = [NSURL fileURLWithPath:path];
    
    //Creates the AVAudioPlayer mainSong and fills it with the song from the above URL
    AVAudioPlayer *mainSong = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
              [mainSong prepareToPlay];
    
    // plays the song
              [mainSong play];
         }
    
    else{
    NSLog(@"Error! %@", path);
         }
    
    
    The code returns no errors or warnings when built but when compiling to run in the simulator I get the following error message:

    The program then ends without running and without the simulator reporting the "normal" the app crashed (or whatever it normally says)... Anyone?
     
  2. InsertWittyName

    InsertWittyName Well-Known Member

    Nov 26, 2008
    202
    1
    0
    Ensure the frameworks you've added to the project are the iPhone versions.
     
  3. Schenk Studios

    Schenk Studios Well-Known Member

    This is a common error and if you look at what the compiler is telling you it's pretty easy to track down and fix. Simply go to YourHardrive/Library/Quicktime and remove the offending components. In this case it looks like a LiveType component. Rinse and repeat.
     
  4. NickFalk

    NickFalk Well-Known Member

    Thanks guys. Looking at your replies the error message makes a lot more sense. :eek:
     

Share This Page