erotsppa
erotsppa

Reputation: 15021

AVAudioPlayer only plays in simulator but not device why?! (iPhone-SDK)

I have the following simple code that plays a sound

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"];
    player =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: soundPath] error:nil];
    player.volume = 1;
    player.numberOfLoops = 0;
[player prepareToPlay];
        [player play];

For some reason this code only plays in the simulator but not the device, any ideas?


Update: Actually I installed AvTouch, a sample app from Apple onto 3.0 and that doens't work either. Is something wrong with AVAudioPlayer?

Upvotes: 2

Views: 1688

Answers (1)

rpetrich
rpetrich

Reputation: 32316

This can happen when the codec used by the audio file is available on OS X, but not the iPhone. It is also caused when the extension doesn't match the actual content of the file. Step through with the debugger and watch the debug console for codec errors or reconvert your file to a supported format with afconvert.

Upvotes: 1

Related Questions