music player in background ios

Solution 1. MPMusicPlayer ipodPlayer

it is actually calling the ipod player, which it is not related to the app anymore. Easy implement, 但有時 load 得多歌 會有d lag, 超建議開多個 tableView 做, 可以 store 住d mediaItemCollection, 因為呢個 framework 係唔會 交返d mediaItemCollection 你, 除非你用 hidden private API

Solution 2. AVPlayer with MPRemoteCommandCenter and MPNowPlayingInfoCenter

you can implement like this. Good Point is the music playing will also appear in the universal toolbar (the bottom one), and click one it, it will show yr app instead of ipod Music. Bad Point is no itunes cloud music can play, and many feature need to implement yrself, 連 previous 都好似無, shuffle 都有d 難做, 但用個d remoteCommand , 下面d 制都可以用, 同埋 用 nowplayinginfocenter 可以 改個 lock screen 個d song info. 無記錯呢個方法要改少少 plist, 有 background audio, 如果做完前者, 出 app無 聲, 試下

MPMusicPlayer ApplicationPlayer is a good choice 如果你想只播歌係你個 app 入面, 因為一出 app 就會 收聲

ref:

http://www.mixedcase.nl/articles/2013/01/29/mediaplayer-apples-worst-framework/ (solution 1)

小米音樂 app (solution 2)