Can i access iPod Library on simulator?

北城余情 提交于 2019-11-27 02:18:14

问题


I am trying some code to open the iPod Library using the simulator but the app crashes with this error:

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

Do I need an actual iPhone to test this code?


回答1:


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




回答2:


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/"



回答3:


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




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/3159716/can-i-access-ipod-library-on-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!