0

I have made an audio player for my app using this guide http://www.ymc.ch/en/building-a-simple-audioplayer-in-ios

The problem i am facing is that the audio stops when the phone gets locked and the audio becomes mute when the ringer is off. Can someone guide me how to keep playing the audio even when the phone is locked.

1 Answers1

0

Firstly you must set Required background mode to App plays audio

enter image description here

And write below codes in didFinishLaunching Method of AppDelegate.m

 NSError *setCategoryErr = nil;
 NSError *activationErr  = nil;
 [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&setCategoryErr];
 [[AVAudioSession sharedInstance] setActive:YES error:&activationErr];

iOS background audio not playing

Community
  • 1
  • 1
Erhan
  • 908
  • 8
  • 19
  • Thanks a ton for your reply. Now the audio doesn't gets paused when the application goes in the background. One more help is required how to implement the pause and play button which are present in the control center. – user3571734 Aug 15 '14 at 04:13
  • You must go to the your app and pause audio programmatically or when phone locked pause button will appear in the screen.you can use that pause button for pause audio. – Erhan Aug 15 '14 at 06:12