iPhone AVAudioPlayer failed to find codec

Posted by Anthony on Stack Overflow See other posts from Stack Overflow or by Anthony
Published on 2010-06-02T05:42:29Z Indexed on 2010/06/02 5:43 UTC
Read the original article Hit count: 291

Filed under:
|

Hello,

I am writing an app that downloads a wav file from a server and needs to play that file. The files use the mulaw codec with 2:1 compression. These wav files are dynamically created by a seperate process so there is no way for me to preconvert the files to a different format or codec, I need to be able to play them as is.

I am using an AVAudioPlayer instance initialized as follows:


NSURL *audioURL = [[NSURL alloc] initWithString:@"http://xxx.../file.wav"];
NSData *audioData = [[NSData alloc] initWithContentsOfURL:audioURL];

AVAudioPlayer *audio = [[AVAudioPlayer alloc] initWithData:audioData error:nil];

[audio play];
However, when the play method executes, I get the following Console Output when executing on the Simulator:

AudioQueue codec policy 1: failed to find a codec of the requested type

I also tried saving the downloaded data to a local file and using a file URL, however that yeilds the same results. The downloaded file does play fine on both Mac and Windows based desktop media players.

The SDK docs state that the mulaw codec is supported on the iPhone, so I am unsure why it is failing to find it. Any assistance would be greatly appreciated.

Thanks.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about avaudioplayer