首页 > 解决方案 > MPMusicPlayerApplicationController 在播放完 30 首歌曲后停止在后台播放

问题描述

我有一个应用程序,使用MPMusicPlayerController.applicationQueuePlayer. 我不断连接到我的后端并使用player.prepend(MPMusicPlayerStoreQueueDescriptor(storeIDs: ids)).

为了测试应用程序,我让它在后台运行了一夜。早上没有播放音乐,锁屏没有显示任何音乐控件,我的应用程序没有运行 - 好像当音乐停止时 ios 杀死了我的应用程序,因为它在后台没有做任何事情。当我回到我的应用程序时,播放完全中断,当我尝试播放下一首曲目或重新开始播放时 - 没有任何效果,我需要终止应用程序并重新开始。

我做了几次这个测试,每次大约 1.5 小时后,应用程序在播放 30 首歌曲后停止播放。有趣的是,我总是使用 player.prepend() 预先添加 30 首歌曲,但是,调试显示歌曲队列实际上更大,比如 105 首左右。当我查看日志时,我会在这 1.5 小时内看到来自音乐播放器的所有可能的错误日志和警告,但在那段时间音乐播放正常。一个有趣的日志TIMEOUT在最后,尽管在这 1.5 小时内我收到了 4 次类似的消息,但最后一个结束了我的应用程序。

是带有时间戳的完整日志,过滤后只留下与媒体播放器相关的内容。这里是其中的一些:

2019-11-30 04:04:36.175688+0100 MyApp[4278:1630772] [Middleware] TIMEOUT Request: <MPCPlayerRequest: 0x280d0a520 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> timing out.
2019-11-30 04:04:36.221643+0100 MyApp[4278:1630772] [Middleware] FINISH Request: <MPCPlayerRequest: 0x280d56ac0 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> Response: (null) [5.396877s] error: Error Domain=MPRequestErrorDomain Code=2 "(null)"
2019-11-30 04:04:36.227077+0100 MyApp[4278:1630772] [Middleware] FINISH Request: <MPCPlayerRequest: 0x280d54240 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> Response: (null) [0.113625s] error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x28318f180 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 04:04:36.229159+0100 MyApp[4278:1630772] [Middleware] RRC <MPCPlayerRequest 0x280d61710>: Request failed with error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x28318f180 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}


OPENING THE APP NEXT DAY ->


2019-11-30 13:01:33.528720+0100 MyApp[4278:1711694] [SDKPlayback] -[MPMusicPlayerController prependQueueDescriptor] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 125" UserInfo={NSDebugDescription=Failed to send command 125, NSUnderlyingError=0x2831bdef0 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 125 (MRSendCommandError = 5)" UserInfo={NSDebugDescription=Failed to send command 125 (MRSendCommandError = 5)}}}
2019-11-30 13:01:33.667624+0100 MyApp[4278:1630937] [] nw_read_request_report [C61] Receive failed with error "Software caused connection abort"
2019-11-30 13:01:33.668843+0100 MyApp[4278:1630937] [] nw_read_request_report [C30] Receive failed with error "Software caused connection abort"
2019-11-30 13:01:33.683226+0100 MyApp[4278:1711697] [Middleware] FINISH Request: <MPCPlayerRequest: 0x280d337b0 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> Response: (null) [0.174930s] error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x2831784e0 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:33.683451+0100 MyApp[4278:1711694] [Middleware] RRC <MPCPlayerRequest 0x280d61710>: Request failed with error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x2831784e0 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:33.687983+0100 MyApp[4278:1630937] [] nw_read_request_report [C61] Receive failed with error "Software caused connection abort"
2019-11-30 13:01:33.701848+0100 MyApp[4278:1630937] [] nw_read_request_report [C30] Receive failed with error "Software caused connection abort"
2019-11-30 13:01:33.799727+0100 MyApp[4278:1630937] Task <3A190957-09C8-416C-8B08-DCBE691C35A0>.<1034> HTTP load failed, 190/0 bytes (error code: -1005 [1:53])
2019-11-30 13:01:33.800991+0100 MyApp[4278:1711694] Task <3A190957-09C8-416C-8B08-DCBE691C35A0>.<1034> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=53, NSUnderlyingError=0x283014a50 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x281c7df90 [0x1d868f5e0]>{length = 16, capacity = 16, bytes = 0x100201bb8fcc65250000000000000000}, _kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <3A190957-09C8-416C-8B08-DCBE691C35A0>.<1034>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <3A190957-09C8-416C-8B08-DCBE691C35A0>.<1034>"
), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://<mybackend>/updatePlaybackInfo, NSErrorFailingURLKey=https://<mybackend>/updatePlaybackInfo, _kCFStreamErrorDomainKey=1}
2019-11-30 13:01:33.801301+0100 MyApp[4278:1711694] [Error]: The network connection was lost. (Code: 100, Version: 1.17.3)
2019-11-30 13:01:33.801515+0100 MyApp[4278:1711694] [Error]: Network connection failed. Making attempt 1 after sleeping for 1.390448 seconds.
2019-11-30 13:01:33.971848+0100 MyApp[4278:1711694] [Middleware] FINISH Request: <MPCPlayerRequest: 0x280d2abe0 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> Response: (null) [0.037286s] error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x283050210 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:33.973632+0100 MyApp[4278:1630937] [Middleware] RRC <MPCPlayerRequest 0x280d61710>: Request failed with error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x283050210 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:34.277935+0100 MyApp[4278:1630937] [Middleware] FINISH Request: <MPCPlayerRequest: 0x280d6b060 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> Response: (null) [0.002645s] error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x28302d560 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:34.278317+0100 MyApp[4278:1711695] [Middleware] RRC <MPCPlayerRequest 0x280d61710>: Request failed with error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x28302d560 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:34.503560+0100 MyApp[4278:1630937] [Middleware] FINISH Request: <MPCPlayerRequest: 0x280d2b180 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> Response: (null) [0.014466s] error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x283051260 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:34.505085+0100 MyApp[4278:1711695] [Middleware] RRC <MPCPlayerRequest 0x280d61710>: Request failed with error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x283051260 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
2019-11-30 13:01:34.873151+0100 MyApp[4278:1711695] [Middleware] FINISH Request: <MPCPlayerRequest: 0x280d68c60 label=MPMusicPlayerController-applicationMusicPlayer playerPath=<MPCPlayerPath: route=<MPAVEndpointRoute: 0x280a0a940 name=iPhone uid=LOCAL> bundleID=com.apple.MediaPlayer.RemotePlayerService pid=4281 playerID=MPMusicPlayerApplicationController>> Response: (null) [0.004019s] error: Error Domain=MPRequestErrorDomain Code=1 "(null)" UserInfo={MPRequestUnderlyingErrorsUserInfoKey=(
    "Error Domain=MPCPlayerRequestErrorDomain Code=2000 \"Failed to get play queue identifers\" UserInfo={NSDebugDescription=Failed to get play queue identifers, NSUnderlyingError=0x283084600 {Error Domain=kMRMediaRemoteFrameworkErrorDomain Code=35 \"Could not find the specified now playing client\" UserInfo={NSLocalizedDescription=Could not find the specified now playing client}}}"
)}
...

标签: iosmpmusicplayercontrollerapple-music

解决方案


推荐阅读