Trying this:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
if (error) {
NSLog(@"Error setting category: %@", [error description]);
}
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.
Help please!
EDIT
Audio Playback:
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");
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.
Only look at the error
variable if the return value of setCategory:error:
is NO
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With