iPhone: How to know music item is unsynced?
-
20-06-2021 - |
Question
I'm creating a music app.
Are there a way to know if MPMediaItem is unsynced while my app is playing it or displaying it on a table view?
On a table view, now I check if MPMediaItem is nil or not.
Is it good way?
A playing MPMediaItem doesn't become nil after it is unsynced.
So I can't know it is unsynced or not.
I thought there was a notification of syncing iTunes.
But I can't find such notification.
Solution
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(notification_iPodLibraryDidChange:)
name: MPMediaLibraryDidChangeNotification
object:nil];
[[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];
Not sure what happens if your library changes under you but I suppose it would be easy enough to check using the above notification.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow