Ad

SpeakHere Sample Can't Play Sound Which Loads From Internet

- 1 answer

I'd like to play sound file which loaded from internet, so I tried to start from iPhone SDK SpeakHere sample. I recorded the sound, then saved and uploaded to the internet, I could download that file and play without problem from sound tools. But when I tried to play that URL from SpeakHere, I am getting error Program received signal: “EXC_BAD_ACCESS”.

After trace around, I found that the in -[AudioPlayer calculateSizesFor:], it set bufferByteSize to a huge number 806128768, which caused buffer allocation failed.

And that because in

AudioFileGetProperty(audioFileID, kAudioFilePropertyPacketSizeUpperBound, &propertySize, &maxPacketSize);

The maxPacketSize returned is 806128768.

I am wondering how to make AudioFileGetProperty work.

My sound file is here, you could right-click and download from here.

I am using this way to set the URL in the -[AudioViewController playOrStop] method:

// AudioPlayer *thePlayer = [[AudioPlayer alloc] initWithURL: self.soundFileURL];
AudioPlayer *thePlayer = [[AudioPlayer alloc] initWithURL:
    [NSURL URLWithString: @"http://chineseresume.com/localbiz/uploads/myfilename_7_Recording.caf"]];

Any suggestion is highly welcome.

Ad

Answer

Yes, you need to use Audio File Stream Services to play directly from the internet.

I found the "AudioFileStreamExample" example useful, which should be installed in

/Developer/Examples/CoreAudio/Services/AudioFileStreamExample/

Also, Matt Gallagher has an article called "Streaming and playing an MP3 stream" that includes iPhone example code. I haven't looked at it carefully, but it seems like it may be helpful to you.

Ad
source: stackoverflow.com
Ad