Ios 断言失败:电影播放器的激活状态错误(1)

Ios 断言失败:电影播放器的激活状态错误(1),ios,mpmovieplayercontroller,Ios,Mpmovieplayercontroller,我正在一个页面上的iPad应用程序中播放一个视频(m4v),然后它会转到另一个播放另一个视频的视图控制器。 它播放得很好,但当第二个视频播放完后,就会抛出断言失败 错误是: *** Assertion failure in -[MPMoviePlayerControllerNew _moviePlayerDidBecomeActiveNotification:], /SourceCache/MobileMusicPlayer_Sim/MobileMusicPlayer-1137.39/SDK/M

我正在一个页面上的iPad应用程序中播放一个视频(m4v),然后它会转到另一个播放另一个视频的视图控制器。 它播放得很好,但当第二个视频播放完后,就会抛出断言失败

错误是:

*** Assertion failure in -[MPMoviePlayerControllerNew _moviePlayerDidBecomeActiveNotification:], /SourceCache/MobileMusicPlayer_Sim/MobileMusicPlayer-1137.39/SDK/MPMoviePlayerController.m:1236
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'movie player <MPMoviePlayerControllerNew: 0x623f6b0> has wrong activation state (1)'
*** Call stack at first throw:
(
0   CoreFoundation                      0x015e35a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x01737313 objc_exception_throw + 44
2   CoreFoundation                      0x0159bef8 +[NSException raise:format:arguments:] + 136
3   Foundation                          0x001ea3bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4   MediaPlayer                         0x00522850 -[MPMoviePlayerControllerNew _moviePlayerDidBecomeActiveNotification:] + 204
5   Foundation                          0x00159669 _nsnote_callback + 145
6   CoreFoundation                      0x015bb9f9 __CFXNotificationPost_old + 745
7   CoreFoundation                      0x0153a93a _CFXNotificationPostNotification + 186
8   Foundation                          0x0014f20e -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
9   MediaPlayer                         0x00521e08 -[MPMoviePlayerControllerNew _postNotificationName:object:] + 56
10  MediaPlayer                         0x005293f7 -[MPMoviePlayerControllerNew _ensureActive] + 158
11  MediaPlayer                         0x005242e8 -[MPMoviePlayerControllerNew setControlStyle:] + 45
12  Restore Sensor                      0x00073cfe -[MRSPresentationSlide2 viewDidLoad] + 334
13  UIKit                               0x00958089 -[UIViewController view] + 179
14  Restore Sensor                      0x00071ed8 -[MRSPresentationController pushViewOnScreen:] + 632
15  Restore Sensor                      0x0007395d -[MRSPresentationSlide1 moviePlayBackDidFinish:] + 365
16  Foundation                          0x00159669 _nsnote_callback + 145
17  CoreFoundation                      0x015bb9f9 __CFXNotificationPost_old + 745
18  CoreFoundation                      0x0153a93a _CFXNotificationPostNotification + 186
19  Foundation                          0x0014f20e -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
20  MediaPlayer                         0x00521d24 -[MPMoviePlayerControllerNew _postDidFinishNotificationWithUserInfo:] + 69
21  Foundation                          0x00159669 _nsnote_callback + 145
22  CoreFoundation                      0x015bb9f9 __CFXNotificationPost_old + 745
23  CoreFoundation                      0x0153a93a _CFXNotificationPostNotification + 186
24  Foundation                          0x0014f20e -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
25  MediaPlayer                         0x0053d974 -[MPAVController _itemPlaybackDidEndNotification:] + 491
26  Foundation                          0x00159669 _nsnote_callback + 145
27  CoreFoundation                      0x015bb9f9 __CFXNotificationPost_old + 745
28  CoreFoundation                      0x0153a93a _CFXNotificationPostNotification + 186
29  Foundation                          0x0014f20e -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
30  Celestial                           0x025907a7 -[NSObject(NSObject_AVShared) postNotificationWithDescription:] + 176
31  Celestial                           0x02594a7d -[AVController itemHasFinishedPlayingNotification:] + 169
32  Celestial                           0x025989ca -[AVController fpItemNotification:sender:] + 2177
33  Celestial                           0x025a2a8d -[AVPlaybackItem fpItemNotificationInfo:] + 1473
34  Celestial                           0x02590f51 -[AVObjectRegistry safeInvokeWithDescription:] + 211
35  Foundation                          0x0016e94e __NSThreadPerformPerform + 251
36  CoreFoundation                      0x015c48ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
37  CoreFoundation                      0x0152288b __CFRunLoopDoSources0 + 571
38  CoreFoundation                      0x01521d86 __CFRunLoopRun + 470
39  CoreFoundation                      0x01521840 CFRunLoopRunSpecific + 208
40  CoreFoundation                      0x01521761 CFRunLoopRunInMode + 97
41  GraphicsServices                    0x0304f1c4 GSEventRunModal + 217
42  GraphicsServices                    0x0304f289 GSEventRun + 115
43  UIKit                               0x008b6c93 UIApplicationMain + 1160
44  Restore Sensor                      0x00002121 main + 177
45  Restore Sensor                      0x00002065 start + 53
)
terminate called throwing an exception
***-[MPMoviePlayerControllerNew\u movieplayerddebecomeactivationfication:],/SourceCache/MobileMusicPlayer\u Sim/MobileMusicPlayer-1137.39/SDK/MPMoviePlayerController.m:1236中的断言失败
***由于未捕获异常“NSInternalInconsistencyException”而终止应用程序,原因是:“电影播放器的激活状态错误(1)”
***第一次抛出时调用堆栈:
(
0 CoreFoundation 0x015e35a9例外预处理+185
1 libobjc.A.dylib 0x01737313 objc_异常_抛出+44
2 CoreFoundation 0x0159bef8+[N异常提升:格式:参数:][136
3基金会0x1001EA3BB-[ NSRealStutsHuffer-HooReuluryIn方法:对象:文件:文件号:描述:] + 116
4 MediaPlayer 0x00522850-[MPMoviePlayerController新(U MoviePlayerIDBECOMEActiveNotification:+204
5基金会0x00 15966 9 NoNo.KelBead + 145
6 CoreFoundation 0x015bb9f9\uuu CFX通知POST\u old+745
7 CoreFoundation 0x0153a93a _CFXNotificationPostNotification+186
8基金会0x014F20E - [ NSnPosiCICTeCsPoestPosiTrimeTrimeNo:对象:用户信息:] + 134
9 MediaPlayer 0x00521e08-[MPMoviePlayerController新发布通知名称:对象:][56
10 MediaPlayer 0x005293f7-[MPMoviePlayerController新建]+158
11 MediaPlayer 0x005242e8-[MPMoviePlayerController新设置控件样式:+45
12恢复传感器0x00073cfe-[MRSPresentationsSlide2 viewDidLoad]+334
13 UIKit 0x00958089-[UIViewController视图]+179
14恢复传感器0x00071ed8-[MRSPresentationController按钮视图屏幕:+632
15还原传感器0x0007395d-[MRSPresentationsSlide1电影回放完成:+365
16基金会0x00 15966 9 NoNo.KelBead + 145
17 CoreFoundation 0x015bb9f9\uuu CFXNotificationPost\u old+745
18 CoreFoundation 0x0153a93a _CFXNotificationPostNotification+186
19基金会0x014F20E - [ NSnPosiCICTeCsPoestPosiTrimeTrimeNo:对象:用户信息:] + 134
20 MediaPlayer 0x00521d24-[MPMoviePlayerControl\u postDidFinishNotificationWithUserInfo:+69
21基金会0x00 15966 9 NoNo.KelBead + 145
22 CoreFoundation 0x015bb9f9\uuu CFXNotificationPost\u old+745
23 CoreFoundation 0x0153a93a _CFXNotificationPostNotification+186
24基金会0x014F20E - [ NSnPosiCICTeCsPoestPosiTrimeTrimeNo:对象:用户信息:] + 134
25 MediaPlayer 0x0053d974-[MPAVController\u ItemPlaybackDiEndNotification:+491
26基金会0x00 15966 9 NoNo.KelBead + 145
27 CoreFoundation 0x015bb9f9\uuu CFXNotificationPost\u old+745
28 CoreFoundation 0x0153a93a _CFXNotificationPostNotification+186
29基金会0x014F20E - [ NSnPosiCICTeCsPoestPosiTrimeTrimeNo:对象:用户信息:] + 134
30天体0x025907a7-[NSObject(NSObject_AVShared)postNotificationWithDescription:+176
31 0x02594a7d-[AVController项已完成播放通知:][169
32 0x025989ca-[AVController fpItemNotification:发送方:][2177
33 0x025a2a8d-[AVPlaybackItem fpItemNotificationInfo:+1473
34天体0x02590f51-[AVObjectRegistry safeInvokeWithDescription:][211
35基金会0x0.16E94E,NSTReRePrimeExp+ 251
36 CoreFoundation 0x015c48ff\uuuu CFRUNLOOP\u正在调用\uu OUT\uu到\uu A\uu源0\uu执行\uu功能\uuu15
37 CoreFoundation 0x0152288b u cfrunloopdosources 0+571
38 CoreFoundation 0x01521d86 _ucfrunlooprun+470
39 CoreFoundation 0x01521840 CFRunLoopRunSpecific+208
40 CoreFoundation 0x01521761 CFRunLoopRunInMode+97
41图形服务0x0304f1c4 GSEventRunModal+217
42图形服务0x0304f289 GSEventRun+115
43 UIKit 0x008b6c93 UIApplicationMain+1160
44恢复传感器0x00002121主+177
45恢复传感器0x00002065启动+53
)
终止引发异常的调用
有人知道我为什么会出现这个错误吗?

我发现了这个问题。
第一个视频没有删除MPMoviePlayerPlaybackDidFinishNotification通知,因此第二个视频被多次加载。

如果您有多个电影播放器,请确保仅在该播放器上注册通知。e、 g:

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
           selector:@selector(moviePlaybackStateChanged:) 
               name:MPMoviePlayerPlaybackDidFinishNotification 
            object:self.movieController];
这样可以确保您只收到来自正确播放机的通知。

这至少为我解决了问题。

在重新初始化之前,请停止播放器


[播放名称停止]

您好,我没有注册任何通知,但收到了相同的错误(崩溃)。你能帮忙吗?提前谢谢。