【发布时间】:2015-01-01 08:12:27
【问题描述】:
我正在使用以下代码从设备播放歌曲。我为 MPMusicPlayerController 添加了通知以识别播放器的状态。
self.musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePlaybackStateChanged:) name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:self.musicPlayer];
[self.musicPlayer beginGeneratingPlaybackNotifications];
[self.musicPlayer setRepeatMode: MPMusicRepeatModeNone];
musicplayer 播放歌曲时会调用以下方法两次。
-(void)handlePlaybackStateChanged :(id )notification
我的问题为什么它被调用了两次?任何帮助将不胜感激。
【问题讨论】:
-
检查 this 所在的函数没有被调用两次,并尝试记录通知并添加断点以确定它何时被调用。
标签: ios notifications mpmusicplayercontroller