2017-02-24 135 views
4
2017-02-24 14:56:44.280 PropertyManager[10172:5336578] 14:56:44.280 ERROR: [0x1a0a24000] AVAudioSession.mm:692: -[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session. 

2017-02-24 14:56:44.281 PropertyManager[10172:5336578] error === Error Domain=NSOSStatusErrorDomain Code=560030580 "(null)" 
PropertyManager was compiled with optimization - stepping may behave oddly; variables may not be available. 

回答

4

錯誤日誌的音頻會議是非常簡潔的自我表現:

Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session 

它告訴你的問題,也解決方案。

現在你正在做這樣的事情:

[[AVAudioSession sharedInstance] setActive:NO 
       withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation 
              error:nil]; 

你應該然而,首先停止音頻播放器實例,然後設置激活狀態爲是或否

[yourAudioPlayer stop]; 
[[AVAudioSession sharedInstance] setActive:NO 
        withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation 
               error:nil]; 

參考到Apple文檔以查看enum AudioSessionSetActiveOption的值。

另見:蘋果文檔上setActive:withOptions方法

至於你的第二個錯誤

PropertyManager was compiled with optimization - stepping may behave oddly; variables may not be available. 

看到this excellent answer

+0

[yourAudioPlayer stop]應該是[yourAudioPlayer pause]。 –

+0

@TheiCoder嗯,爲什麼?它可以是任何一種,這取決於OP的需求。 – NSNoob