AVAudioPlayer returns success but no sound from device

本小妞迷上赌 提交于 2019-12-06 00:04:17

OK - got it figured out. I had not configured the AVAudioSession for my app. Did something very simple as follows (copied from Apple's example code):

[[AVAudioSession sharedInstance] setDelegate: self];
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
if (setCategoryError)
    NSLog(@"Error setting category! %@", setCategoryError);

Sound now plays - plus learned a lot about how to control playback through screen locks, etc., which will be valuable.

Did you check if you get anything from the error?

if(error) {
    NSLog( @"%@", [error localizedDescription] );
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!