Playing a sound > 30sec just doesn't work for me

Discussion in 'iOS Programming' started by holycow, Jan 21, 2009.

  1. holycow macrumors newbie

    Joined:
    May 28, 2006
    #1
    I cannot for the life of me get an mp3 file to play using AVFoundation and it is driving me crazy. It's not that much code. The code will compile without problems and when I run it in the 2.2 Simulator, no sound comes out. Would someone mind posting a sample xcode project or some code that is confirmed to be working and plays a single audio file? I have no idea if this is my setup or what. I can play shorter system sounds just fine.

    I'm just using this sample code:

    Code:
    NSString *path = [[NSBundle mainBundle] pathForResource:@"dream" ofType:@"m4a"];
    AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
    theAudio.delegate = self;
    [theAudio play];
    
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    You sure you meant:
    Code:
    pathForResource:@"dream" ofType:@"m4a"
    and not
    Code:
    pathForResource:@"dream" ofType:@"mp3"
    ?
     
  3. holycow thread starter macrumors newbie

    Joined:
    May 28, 2006
    #3
    yeah, that's not the problem. does the simulator just not play sounds like that? I haven't gotten a chance to try it on a device, but I figured it wouldn't since it's not working in the simulator.
     
  4. holycow thread starter macrumors newbie

    Joined:
    May 28, 2006
    #4
    Ok, I got it to work on my actual iPhone, but the simulator just freezes up. It does that with other sample xcode projects that play sounds too. Weird.
     

Share This Page