Hi I am developing an application that plays another mp3 buffer loop for 5 minutes. When the application runs in the foreground or in iphone standby mode, it plays normally, but when I try in the background, but it gives me this error:
Thu Feb 17 00:05:06 unknown mediaserverd [2303]: 00: 05: 06.158 AudioQueue: Error -12985 from AudioSessionSetClientPlayState (3582) Thu Feb 17 00:05:06 Unknown mediaserverd [2303]: 00: 05: 06.167 AudioQueue: Error -12985 of AudioSessionSetClientPlayState (3582)
Additional info: when I play buffered mp3 (first with root) in cicle, it plays well in the background. I am also trying to save buffered mp3 data to an mp3 file and then play, but this is the same problem. I searched for this error, but I did not find the relevant information.
Thanks in advance.
There (I think) the corresponding code:
-(void) prepareAudio {
[[AVAudioSession sharedInstance] setDelegate: self];
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
UInt32 doSetProperty = 0;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers,
sizeof (doSetProperty),
&doSetProperty
);
NSError *activationError = nil;
[[AVAudioSession sharedInstance] setActive: YES error: &activationError];
}
- (void)finishedReceivingData:(NSData *)data {
if(data == nil) {
NSLog(@"cdata nil");
return;
}
if (player != nil) {
[player release];
player = nil;
}
player = [[AVAudioPlayer alloc] initWithData:data error: nil];
[player setVolume:0.1];
[player play];
}
source
share