问题描述
我想播放从互联网加载的声音文件,所以我试着从iPhone SDK SpeakHere示例开始。我录制的声音,然后保存并上传到互联网,我可以下载该文件,播放没有问题,从声音工具。但是当我试图从SpeakHere播放该URL时,我收到错误程序收到的信号:EXC_BAD_ACCESS
。
跟踪之后,我发现在 - [AudioPlayer calculateSizesFor:]
中,它将 bufferByteSize
设置为一个巨大的数806128768,导致缓冲区分配失败。
这是因为
AudioFileGetProperty(audioFileID,kAudioFilePropertyPacketSizeUpperBound,& propertySize,& maxPacketSize);
返回的 maxPacketSize
是806128768。 p>
我想知道如何让 AudioFileGetProperty
工作。
我的声音文件是,
,您可以右键点击并从中下载。
我使用这种方式在 - [AudioViewController playOrStop]
方法中设置URL:
// AudioPlayer * thePlayer = [[AudioPlayer alloc] initWithURL:self.soundFileURL];
AudioPlayer * thePlayer = [[AudioPlayer alloc] initWithURL:
[NSURL URLWithString:@http://chineseresume.com/localbiz/uploads/myfilename_7_Recording.caf]];
欢迎任何建议。
是的,您需要使用直接从互联网播放。
我发现AudioFileStreamExample示例有用,
/ Developer / Examples / CoreAudio / Services / AudioFileStreamExample /
此外,Matt Gallagher有一篇文章,其中包含iPhone示例代码。我没有仔细看过它,但它似乎可能对你有帮助。
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.
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.
这篇关于说话样品不能播放从互联网加载的声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!