AVAudioPlayer 返回错误“pty?”
AVAudioPlayer 似乎无法处理某些使用 AudioStreamer (https://github.com/mattgallagher/AudioStreamer) 可以处理的音频文件,即使作为本地文件播放也是如此。
我的问题:
1)什么类型的音频文件会生成错误代码“pty?”。注意:音频文件在 QuickTime Player 中可以正常播放。
2) 以下代码使用此音频文件会生成相同的错误:
UInt32 size;
OSStatus err = AudioFileGetPropertyInfo([self audioFileID], kAudioFilePropertyChannelLayout, &size, NULL);
但是在同一音频文件上使用流 api 这将起作用(好的,会获取不同的属性,但问题是为什么不能询问通道布局?):
err = AudioFileStreamGetPropertyInfo(inAudioFileStream, kAudioFileStreamProperty_FormatList, &formatListSize, &outWriteable);
我要知道,如果您流式传输音频,则需要使用流 api,因为当时只有文件的一部分可用。但是当完整的文件位于文件系统中时,文件音频 api 应该可以使用(?)
3)即使文件是本地的,是否建议使用流 api?欢迎提出如何实施的好想法。
让我困惑的是为什么 AudioFile* api 失败而 AudioFileStream* 有效。
AVAudioPlayer seems not to handle some audio files that can be handled if using AudioStreamer (https://github.com/mattgallagher/AudioStreamer) even when played as a local file.
My questions:
1) What type of audio files generate the error code "pty?". NOTE: Audio file plays fine in QuickTime Player.
2) The following code generates the same error using this audio file:
UInt32 size;
OSStatus err = AudioFileGetPropertyInfo([self audioFileID], kAudioFilePropertyChannelLayout, &size, NULL);
But using the stream api on the same audio file this will work (ok different properties are fetched but then the question is why can't channel layout be asked?):
err = AudioFileStreamGetPropertyInfo(inAudioFileStream, kAudioFileStreamProperty_FormatList, &formatListSize, &outWriteable);
I know that if you stream audio you need to use the stream api because only a part of the file is available at the time. But when the complete file is in the filesystem the file audio api should be possible to use (?)
3) Is it recommended to use stream api even if the file is local? Good ideas how to implement it are welcome.
What puzzles me is why AudioFile* api fails were AudioFileStream* works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论