AVAudioSession setCategory错误 [英] AVAudioSession setCategory error
本文介绍了AVAudioSession setCategory错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试一下:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
if (error) {
NSLog(@"Error setting category: %@", [error description]);
}
重新获得错误错误设置类别:UIView",但不确定如何解决此问题.不能完全确定它在告诉我什么.
Getting the error back "Error setting category: UIView" but am not sure how to go about fixing this. Not entirely sure what it's telling me.
请帮助!
编辑
音频播放:
NSURL *audioFileURL = [[NSBundle mainBundle] URLForResource:@"DemoSong" withExtension:@"m4a"];
NSError *error;
self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL error:&error];
if (error) {
NSLog(@"%@", [error localizedDescription]);
}
[_audioPlayer setNumberOfLoops:-1];
[_audioPlayer setMeteringEnabled:YES];
[_visualizer setAudioPlayer:_audioPlayer];
[_audioPlayer prepareToPlay];
[_audioPlayer play];
NSLog(@"play audio");
推荐答案
您应该检查[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error]
的返回值,因为成功返回YES
,失败返回NO
.
You should check the return value of [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error]
, as it returns YES
if it succeeded and NO
if it failed.
如果setCategory:error:
的返回值为NO
,则仅查看error
变量.
Only look at the error
variable if the return value of setCategory:error:
is NO
.
这篇关于AVAudioSession setCategory错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文