How to play audio in the background when I press the iphone button to “minimize” the application?

I am working on a new iphone sound application.

When I open the application, the audio loads and starts. If I press the iphone button to “minimize” the application, the sound was stopped. I need a sound playing in the background.

How am i doing this?

thanks

+4
source share
2 answers

To play in the background, add an array entry called "UIBackgroundModes" to your .plist file and add "audio" as an element of the array.

.plist:

UIBackgroundModes Array Item0 String audio 
+1
source

Try also a look at AVAudioSession.

  AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayback error:nil]; [session setActive:YES error:nil]; 

This should help.

+1
source

Source: https://habr.com/ru/post/943690/


All Articles