0

I am developing a project that play music in the background. Basically, the app will continue play the audio file even the screen is locked.

I have setup the background mode by selecting audio option, as you can see in this photo: enter image description here

It works fine as I expected that the app keep playing the audio when users lock the screen. However, when a call is received, the app stop playing. I thought it may start playing again after the phone call finished. However, it didn't.

I check a few webs, should I do some modification in the AppDelegate file, such as this method:

func applicationWillResignActive(_ application: UIApplication)

Basically, what I am trying to figure out is, how can I pause the audio when phone call or other notifications come and resume playing the audio when the phone call or other notifications finished.

Thanks in advance.

Nan
  • 496
  • 3
  • 21
  • 1
    As far as I know, It does not un pauses it self. Try registering AVAudioSessionInterruptionNotification and once the interruption is done try un pausing the audio. – Gihan Jul 05 '17 at 06:23
  • Check this out https://stackoverflow.com/questions/9476698/background-audio-doesnt-resume-after-a-call?rq=1 – Jas_meet Jul 05 '17 at 06:26

0 Answers0