AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers)已弃用

时间:2016-01-28 13:14:54

标签: objective-c iphone xcode avaudiosession

我用过

 UInt32 doSetProperty = 0;
    OSStatus status1 = AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);

我看到它已被弃用,我改为:

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

执行此操作后,不再调用remoteControlReceivedWithEvent

在我所做的两个版本中:

success &= [[AVAudioSession sharedInstance] setActive:YES error:&error];

有没有人遇到过这种问题?

1 个答案:

答案 0 :(得分:-1)

您导入了AVFoundation吗?

#import <AVFoundation/AVFoundation.h>

你忘了设置代表吗?

[[AVAudioSession sharedInstance] setDelegate:self];
[[AVAudioSession sharedInstance] setActive: YES error: nil];