AudioSessionSetProperty在iOS 7.0中已弃用,因此如何设置kAudioSessionProperty_OverrideCategoryMixWithOthers

时间:2014-02-10 16:23:50

标签: ios iphone xcode

需要非弃用的替代品(顺便说一下,我认为这仍然在link的当前苹果文档中):

OSStatus propertySetError = 0;
UInt32 allowMixing = true;

propertySetError = AudioSessionSetProperty (
                       kAudioSessionProperty_OverrideCategoryMixWithOthers,  // 1
                       sizeof (allowMixing),                                 // 2
                       &allowMixing                                          // 3
                   );

感谢;

1 个答案:

答案 0 :(得分:47)

使用AVAudioSession

AVAudioSession *session = [AVAudioSession sharedInstance];

NSError *setCategoryError = nil;
if (![session setCategory:AVAudioSessionCategoryPlayback
         withOptions:AVAudioSessionCategoryOptionMixWithOthers
         error:&setCategoryError]) {
    // handle error
}