I am using a music player property for iPod player controller.
// .h
@property (nonatomic, retain) MPMusicPlayerController *ipodPlayer;
// .m
ipodPlayer = [MPMusicPlayerController iPodMusicPlayer];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector(changedPlaybackState:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:ipodPlayer];
[notificationCenter addObserver:self selector:@selector(changedNowPlayingItem:) name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification object:ipodPlayer];
[ipodPlayer beginGeneratingPlaybackNotifications];
During background processing, if iPod player app is terminated, the console prints out:
MediaPlayer: Message playbackState timed out.
If it doesn't crash(or freezes, slowing performance), the notification is not being sent to my observing methods anymore. I can still send messages like:
[ipodPlayer pause];
[ipodPlayer play];
[ipodPlayer skipToNextItem];
[ipodPlayer skipToPreviousItem];
but can't receive any notifications
My questions are:
- Is there are way to reassign, reload pointers during runtime? How can I restore the property to be just like when it's first launched?
- How can I catch the messge:"MediaPlayer: Message playbackState timed out." in console output? This is not like using NSLog.
Thank you for helping me.