有人知道这是否可行?
我的音频会话和OpenAL设置如下:
// Allow their music to play in the background
AudioSessionInitialize(NULL, NULL, openALInterruptionListener, (__bridge void *)(self));
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 allowMixing = false;
AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(allowMixing), &allowMixing);
// use the device to make a context
_mContext = alcCreateContext(_mDevice, NULL);
// set my context to the currently active one
alcMakeContextCurrent(_mContext);
我有这样的设置:
- (void)setSoundDucked:(BOOL)soundDucked
{
if(soundDucked)
{
UInt32 allowMixing = true;
AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(allowMixing), &allowMixing);
AudioSessionSetActive(false);
AudioSessionSetActive(true);
}
else
{
UInt32 allowMixing = false;
AudioSessionSetProperty(kAudioSessionProperty_OtherMixableAudioShouldDuck, sizeof(allowMixing), &allowMixing);
AudioSessionSetActive(false);
AudioSessionSetActive(true);
}
}
然而,声音不会消失。如果我注释掉以下几行,它只会躲避:
// use the device to make a context
_mContext = alcCreateContext(_mDevice, NULL);
// set my context to the currently active one
alcMakeContextCurrent(_mContext);
有没有让OpenAL与音频闪避属性玩得很好?