How To Switch music from my app to the ipod

2019-03-02 02:19发布

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条回答
我想做一个坏孩纸
2楼-- · 2019-03-02 02:44

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

查看更多
登录 后发表回答