avoid Headset plugout stops AVAudioPlayer in iOS
问题 In my iPhone app I am using AVAudioPlayer to play the songs...But when I plug out or plugin the headset during song playing, It automatically stops the AVAudioPlayer... I need to run audio player even though these changes occur.. any ideas will be appreciated.Thanks in advance. 回答1: First, you have to tell AVAudioSession the audio behaviour of your app. Apple name this the audio session category , an can be set by [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback