Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

holycow

macrumors member
Original poster
May 28, 2006
35
4
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];
 

holycow

macrumors member
Original poster
May 28, 2006
35
4
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.
 

holycow

macrumors member
Original poster
May 28, 2006
35
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.