pet*_*ine 10 crash notifications background mpmusicplayercontroller ios
我正在使用iPod播放器控制器的音乐播放器属性.
// .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];
Run Code Online (Sandbox Code Playgroud)
在后台处理期间,如果终止iPod播放器应用程序,控制台将打印出:
MediaPlayer: Message playbackState timed out.
Run Code Online (Sandbox Code Playgroud)
如果它没有崩溃(或冻结,降低性能),则不再向我的观察方法发送通知.我仍然可以发送如下消息:
[ipodPlayer pause];
[ipodPlayer play];
[ipodPlayer skipToNextItem];
[ipodPlayer skipToPreviousItem];
Run Code Online (Sandbox Code Playgroud)
但无法收到任何通知
我的问题是:
感谢你们对我的帮助.
更新:
似乎使用assign或weak用于ipodPlayer属性是解决方案.此外,访问它是在假设该属性可能不存在的情况下完成的.经过多次试验和一年在我的应用程序中实际使用它,我认为这是正确的解决方案.
我MpMoviePlayerController在 iOS 5 中也遇到了类似的问题。我找到了一个解决方案。它在这里也可能起作用。
添加:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
Run Code Online (Sandbox Code Playgroud)
在viewDidLoad。
更多我的另一篇文章
| 归档时间: |
|
| 查看次数: |
1896 次 |
| 最近记录: |