iOS 10 错误多次记录导致应用程序挂起

标签 ios objective-c iphone mpmusicplayercontroller ios10

我已经在应用程序商店中有一个音乐流媒体应用程序。 现在我正在通过 Xcode 8.0 beta 在 iOS 10 上测试我的应用程序。

我的应用程序在多个地方持续挂起几秒钟。首先是当启动应用程序本身时,我看到黑屏几秒钟。然后,当启动任何 View Controller 时,也会发生同样的情况。当关闭 View Controller 时,也会发生同样的情况。

每次都会多次记录以下错误。当此错误停止记录时,操作完成。我在网络上没有找到此错误的任何点击:

2016-06-15 21:05:38.407727 APPNAME[1623:409190] [SDKPlayback] MPMusicPlayer: Unable to launch iPod music player server: security policy error
2016-06-15 21:05:38.920961 APPNAME[1623:409190] [SDKPlayback] MPMusicPlayer: Unable to launch iPod music player server: security policy error
2016-06-15 21:05:39.437162 APPNAME[1623:409190] [SDKPlayback] MPMusicPlayer: Unable to launch iPod music player server: security policy error
2016-06-15 21:05:39.950330 APPNAME[1623:409190] [SDKPlayback] MPMusicPlayer: Unable to launch iPod music player server: security policy error

我的应用程序是一个音乐流媒体。我不确定是否应该等待下一个测试版本来测试或将此报告为错误或其他什么?

最佳答案

在没有首先检查 MPMusicPlayerController 实例是否准备好播放的情况下调用该实例上的操作将导致所描述的行为(安全警告并且应用程序将挂起)。以下代码在模拟器上运行时不检查 mediaPlayer.isPreparedToPlay 将复制该行为:

MPMusicPlayerController *mediaPlayer = [MPMusicPlayerController applicationMusicPlayer];
if (mediaPlayer.isPreparedToPlay) {
  mediaPlayer.repeatMode = MPMusicRepeatModeAll;
  mediaPlayer.shuffleMode = MPMusicShuffleModeSongs;
}

并迅速:

let mediaPlayer = MPMusicPlayerController.applicationMusicPlayer()
if mediaPlayer.isPreparedToPlay {
  mediaPlayer.repeatMode = MPMusicRepeatMode.All
  mediaPlayer.shuffleMode = MPMusicShuffleMode.Songs
}

关于iOS 10 错误多次记录导致应用程序挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37848294/

相关文章:

ios - 如何使用 NSPredicate 过滤数组中的多个值?

ios - iPhone ipa 分发 ike Diawi.com 的任何替代方式?这个网站最近几天不能用

ios - 无法将私有(private) pod 添加为其他 pod 中的依赖项?

ios - UITableView 展开和折叠以显示部分或全部单元格

c++ - 单词的 SQL 哈希表

ios - 我可以在界面生成器中设置可访问性标识符吗? Xcode4.2

iphone - 比较两个 NSMutableArray

ios - 如何检查 IndexPath 是否有效?

ios - __LP64__ 和 __arm64__ 在 Cocoa 中存在哪些定义可以在编译时区分平台?它们在哪里或如何定义?

iphone - 传递动画数组时应用程序崩溃