I am developing a music app, where the music continues playing even when the app goes into background and uses beginReceivingRemoteControlEvents so that the user can control the status of the playback by clicking the home button twice on his iPhone/iPad.
I went through the “Music App” Sample developed by Apple where it uses MPMusicPlayerController where it fetches songs from iPod Library, but it stops the song as soon as the app goes to background and does not support beginReceivingRemoteControlEvents.
I checked a few articles where it says use AVPlayer, but it doesnt support fetching music from iPod Library so I am stuck in how to play the music when the app goes into background and it is controlled via remoteEvents.
iPodMusicPlayer will play in the background, but through the iOS iPod Music Player. Your app will not receive notifications in the background. For that, you would need to set up an AVAudioSession and play with AVPlayer.
Check here for more information
Apple has a great resource here
From the Apple Docs:
Make sure you are using
and not
Here is a good article on how to import the library into an AVAudioSession
Add a row to your info.plist file with the name “UIBackgroundModes”
Enter “audio” as the first key.