Guidelines for saving iPod playlist (MPMediaItemCollection) in all sessions

When using the in-app sound in the iPhone SDK, you can allow users to select a list from their ipod library and create a local playlist in the application. If I want to keep this choice, it easily serializes the data and writes it to a file, and then restores it.

Just vanilla like this leads me to the idea that there will be something wrong. For example, what if the user synchronizes and deletes sounds? I can cross them all and request the iPod database during setup, but with lists that can be 50,000 in length, this can take some time.

How do other people do this and some mistakes that I did not know about?

+4
source share
2 answers

I would just do it lazily

If the user wants to play the song, you can request iPod DB, in particular for this song and, possibly, for the entire song β€œAlbum” if the user deletes the album. This will require two database queries before playing each song, but you can check if it is enough, etc.

You can also put the β€œ sync ” option in the application using iPod DB , but as a choice for the user, telling the user a β€œwarning” that it might take some time, maybe even give him an estimate of the time for the size of his particular library.

I think that from a usability / battery point of view, this would be better than querying the entire database every time the application starts or even in the background.

+3
source

First, I posted a response about saving individual MPMediaItems. After some thought and re-reading the documentation for MPMediaPickerControllerDelegate , I think the approach to use is to save the representiveItem property for MPMediaItemCollection and use it to build MPMediaQuery at runtime.

+2
source

Source: https://habr.com/ru/post/1307510/


All Articles