开发者

Can i access iPod Library on simulator?

I am trying some code to open the iPod Library using the simulator but the app cras开发者_如何学编程hes with this error:

MPMediaLibrary: Unable to launch iPod library server: application not found

Do I need an actual iPhone to test this code?


I've had some success using MPMediaLibrary / MPMediaQuery on the simulator (not playing music, but at least able to query for items) and xcode 4.6.3

I used iFunBox to copy these files from my device:

'Raw File System'/iTunes_Control/iTunes/MediaLibrary.sqlitedb
'Raw File System'/iTunes_Control/iTunes/MediaLibrary.sqlitedb-shm
'Raw File System'/iTunes_Control/iTunes/MediaLibrary.sqlitedb-wal
'Raw File System'/iTunes_Control/iTunes/Artwork

onto my mac in the folder:

"~/Library/Application Support/iPhone Simulator/6.1/Media/iTunes_Control/iTunes/"


Yes you need to test on a device to access the media library.


Clarification to answer JosephH:

it even works in Xcode 6 but the files should be placed in a folder:

"~/Library/Developer/CoreSimulator/Devices/########-####-####-####-############/data/Media/iTunes_Control/iTunes"

where ########-####-####-####-############ - will be different for different versions of the simulator phone


I was trying to figure this out as well and since you basically need to use all of the answers given here and it is somewhat outdated I figured I would write a little how to.

I will try to keep this up to date so everyone who wants to use this ability will be able to use it without to much trouble


To add to @JosephH and @Rinat Abidullin's answers, I also found that it is possible to access the music files themselves from the Simulator (at least using the iOS 8 and 9 Simulators from Xcode 7.3). For this to work, I copied the following folders from my iPhone to the corresponding folder on my Mac (in addition to the files @JosephH mentioned):

  • /var/mobile/Media/iTunes_Control/Music
  • /var/mobile/Media/Purchases

The files can then be played by using an AVAudioSession to open the MPMediaItemPropertyAssetURL.

Update: There is also a very good sample project that can be used to easily test this out: GVMusicPlayerController.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜