0
您好我已經把我的應用程序的音頻會議ambientsound, 當我推出了應用程序的拳頭時,她剛剛殺死音樂時播放音樂。 我不希望這種事情發生。 有任何其他的方式來設置這個?應用程序關閉推出
您好我已經把我的應用程序的音頻會議ambientsound, 當我推出了應用程序的拳頭時,她剛剛殺死音樂時播放音樂。 我不希望這種事情發生。 有任何其他的方式來設置這個?應用程序關閉推出
試試這個:
激活音頻會話:
OSStatus activationResult = NULL;
result = AudioSessionSetActive (true);
測試,如果其他音頻播放
UInt32 otherAudioIsPlaying; // 1
UInt32 propertySize = sizeof (otherAudioIsPlaying);
AudioSessionGetProperty ( // 2
kAudioSessionProperty_OtherAudioIsPlaying,
&propertySize,
&otherAudioIsPlaying
);
if (otherAudioIsPlaying) { // 3
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryAmbient
error: nil];
} else {
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategorySoloAmbient
error: nil];
}
如果是,允許混合
OSStatus propertySetError = 0;
UInt32 allowMixing = true;
propertySetError = AudioSessionSetProperty (
kAudioSessionProperty_OverrideCategoryMixWithOthers, // 1
sizeof (allowMixing), // 2
&allowMixing // 3
);
她不好那樣! –
我的回答有幫助嗎? – Oliver
我沒有嘗試,但 –