2011-11-04 55 views
0

您好我已經把我的應用程序的音頻會議ambientsound, 當我推出了應用程序的拳頭時,她剛剛殺死音樂時播放音樂。 我不希望這種事情發生。 有任何其他的方式來設置這個?應用程序關閉推出

+1

她不好那樣! –

+0

我的回答有幫助嗎? – Oliver

+0

我沒有嘗試,但 –

回答

2

試試這個:

激活音頻會話:

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 
        ); 

來源:http://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html