How To Switch music from my app to the ipod

2019-03-02 01:53发布

问题:

i am using MusicPlayerController object in my app to play music. i know that its possible to keep playing my app music when it's terminate on the iphone ipod app.

how can i do it?

回答1:

There are a few things involved.

You have to choose between two music players, the application music player and the iPod music player:

+ (MPMusicPlayerController *)applicationMusicPlayer;
+ (MPMusicPlayerController *)iPodMusicPlayer;

If you choose the iPodMusicPlayer, music will continue to play in the background and the user can stop it using the iPod (or Music) app.

If you choose the applicationMusicPlayer, by default the music will stop when you get sent to the background. If you want to continue playing, you'll have to set UIBackgroundMode in your Info.plist file to tell the system you should continue to run.

See: App States and Multitasking and Info.plist keys