マナーモードでも音を出したい場合は、AudioSessionSetProperty() でカテゴリ指定をすると変更できる。
- (void)loadAudioMode:(BOOL)isLiveMode {
AudioSessionInitialize(NULL, NULL, NULL, NULL);
UInt32 sessionCategory;
if (isLiveMode) {
sessionCategory = kAudioSessionCategory_LiveAudio;
} else {
sessionCategory = kAudioSessionCategory_SoloAmbientSound;
}
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
sizeof(sessionCategory),
&sessionCategory);
AudioSessionSetActive(YES);
}
AudioSirvices クラスに定義してあり、iPhone Core Audio プログラミングの書籍に記載されているも定義が多いです(SDKのバージョンがあがったから?)。
enum { // typedef UInt32 AudioSessionPropertyID
kAudioSessionProperty_PreferredHardwareSampleRate = 'hwsr', // Float64 (get/set)
kAudioSessionProperty_PreferredHardwareIOBufferDuration = 'iobd', // Float32 (get/set)
kAudioSessionProperty_AudioCategory = 'acat', // UInt32 (get/set)
kAudioSessionProperty_AudioRoute = 'rout', // CFStringRef (get only)
kAudioSessionProperty_AudioRouteChange = 'roch', // CFDictionaryRef (property listener)
kAudioSessionProperty_CurrentHardwareSampleRate = 'chsr', // Float64 (get only)
kAudioSessionProperty_CurrentHardwareInputNumberChannels = 'chic', // UInt32 (get only)
kAudioSessionProperty_CurrentHardwareOutputNumberChannels = 'choc', // UInt32 (get only)
kAudioSessionProperty_CurrentHardwareOutputVolume = 'chov', // Float32 (get only/property listener)
kAudioSessionProperty_CurrentHardwareInputLatency = 'cilt', // Float32 (get only)
kAudioSessionProperty_CurrentHardwareOutputLatency = 'colt', // Float32 (get only)
kAudioSessionProperty_CurrentHardwareIOBufferDuration = 'chbd', // Float32 (get only)
kAudioSessionProperty_OtherAudioIsPlaying = 'othr', // UInt32 (get only)
kAudioSessionProperty_OverrideAudioRoute = 'ovrd', // UInt32 (set only)
kAudioSessionProperty_AudioInputAvailable = 'aiav', // UInt32 (get only/property listener)
kAudioSessionProperty_ServerDied = 'died', // UInt32 (property listener)
kAudioSessionProperty_OtherMixableAudioShouldDuck = 'duck', // UInt32 (get/set)
kAudioSessionProperty_OverrideCategoryMixWithOthers = 'cmix', // UInt32 (get, some set)
kAudioSessionProperty_OverrideCategoryDefaultToSpeaker = 'cspk', // UInt32 (get, some set)
kAudioSessionProperty_OverrideCategoryEnableBluetoothInput = 'cblu', // UInt32 (get, some set)
kAudioSessionProperty_InterruptionType = 'type', // UInt32 (get only)
};