应用程序放在后台后AVAssetReader失败,为什么?

时间:2011-09-30 19:54:43

标签: ios avassetreader

我使用AVAssetReader和iPod库进行播放,当我将应用程序放在后台时,它会继续将音频读入播放缓冲区,但当它到达歌曲的结尾并开始阅读下一首歌时它调用startReading时失败。我收到以下错误详情。

Error Domain=AVFoundationErrorDomain Code=-11800 "The operation couldn’t be completed.  (AVFoundationErrorDomain error -11800.)" UserInfo=0x1bfc20 {NSUnderlyingError=0x113e00 "The operation couldn’t be completed. (OSStatus error -12985.)"}
{
    NSUnderlyingError = "Error Domain=NSOSStatusErrorDomain Code=-12985 \"The operation couldn\U2019t be completed. (OSStatus error -12985.)\"";
}

我不知道AVAssetReader是否存在限制?

1 个答案:

答案 0 :(得分:-1)

NSError *sessionError = nil;
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&sessionError];
    UInt32 doSetProperty = 1;
    OSStatus tStatus = AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers,
                                                sizeof (doSetProperty),
                                                &doSetProperty
                                                );
    NSLog(@"AVAudioSession AudioSessionSetProperty status is %@", tStatus);
    [[AVAudioSession sharedInstance] setActive:YES error:&sessionError];
    [[AVAudioSession sharedInstance] setDelegate:self];
    NSLog(@"AVAudioSession setActive Error is %@", sessionError);