MPMediaLibraryDidChangeNotification called twice?

My application uses iPodMusicPlayer, and when it is paused, the user can exit and make changes to the Apple Music application, for example, create or modify a playlist, and then return to their application.

I get the expected MPMediaLibraryDidChangeNotification, and that's fine, and I'm updating my links, etc., but I get a second MPMediaLibraryDidChangeNotification message after about 2 minutes, which I really don't need.

Any ideas on avoiding this second notice?

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notification_iPodLibraryDidChange:) name: MPMediaLibraryDidChangeNotification object:nil];

[[MPMediaLibrary defaultMediaLibrary] beginGeneratingLibraryChangeNotifications];
+3
source share
5 answers
if( !self.lastModifiedDate )        self.lastModifiedDate = [[NSDate alloc] init];
if( [self.lastModifiedDate compare:[[MPMediaLibrary defaultMediaLibrary] lastModifiedDate]] == NSOrderedSame )  return;
self.lastModifiedDate = [[MPMediaLibrary defaultMediaLibrary] lastModifiedDate];

. - , .

0

, . , 12 , 12 . , , ( , iOS 5.1, iOS).

+3

? , viewWillAppear dealloc, , . , , - , , .

2 minutes seems like a long delay time (mine was a few seconds), but it might still be worth checking out.

+1
source

Probably the best way to avoid multiple start of update procedures after several notifications is to set a timer and wait a few seconds before performing the actual update.

+1
source

Delete the beginGeneratingLibraryChangeNotifications command and it will fix it. :) You just get each notification for change, one from the notification center and one from the default library.

0
source

All Articles