开发者

Cannot play a recorded sound on device

开发者 https://www.devze.com 2022-12-29 01:33 出处:网络
I\'m using the exact code from the iPhone Application Program开发者_如何学编程ming Guide Multimedia Support to use AVAudioRecorder to record a file to the disk and then AVAudioPlayer to load and play

I'm using the exact code from the iPhone Application Program开发者_如何学编程ming Guide Multimedia Support to use AVAudioRecorder to record a file to the disk and then AVAudioPlayer to load and play that file.

This is working fine in the simulator but is not working on the device. The file gets loaded (we can see the NSTimeInterval) but does not play (play returns false).

After it didn't work with the sample code from the website, we tried changing to a bunch of different codecs with no success. And of course, the sound is on.

Thanks a bunch.


SOLVED! The problem was that after you set the AVAudioSession category to Record for recording, you have to set it to Play for playing. Sounds obvious now but you know how it is. When you use the Simulator it uses a different underlying implementation so this problem does not show up.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号