MPMoviePlayerController 堆栈溢出
我正在尝试在一个相当简单的 iPhone 应用程序中使用 MPMoviePlayerController
。基本布局是与 UIWindow
xib 文件关联的 UIApplicationDelegate
。在 applicationDidFinishLaunching
方法中,我尝试使用以下代码播放电影:
// Path to the movie
NSString *path = [[NSBundle mainBundle] pathForResource:@"logoscreen" ofType:@"m4v"];
movieURL = [NSURL fileURLWithPath:path];
// Setup the player
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
// Use the new 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
[window addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
执行此代码时,我收到“EXC_BAD_ACCESS”错误,并且 GDB 加载了一个巨大的堆栈(使用“_makeSubtreePerformSelector”)方法重复数千次:
#6633 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6634 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6635 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6636 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6637 0x34b0c9c4 in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:]
#6638 0x34b0c790 in -[UIView(Internal) _addSubview:positioned:relativeTo:]
#6639 0x34b0c408 in -[UIView(Hierarchy) addSubview:]
#6640 0x33f81928 in -[MPInlineVideoViewController _transitionToFullscreenAnimated:]
#6641 0x33f7df5c in -[MPInlineVideoViewController setFullscreen:animated:]
#6642 0x33f05998 in -[MPMoviePlayerControllerNew setFullscreen:animated:]
#6643 0x33f059cc in -[MPMoviePlayerControllerNew setFullscreen:]
#6644 0x33f06b2c in -[MPMoviePlayerController setFullscreen:]
#6645 0x00002ab0 in -[GiyapLiteAppDelegate playMovie:] at GiyapLiteAppDelegate.m:67
#6646 0x000028a2 in -[GiyapLiteAppDelegate applicationDidFinishLaunching:] at GiyapLiteAppDelegate.m:38
#6647 0x34b16154 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:]
#6648 0x34cc46d4 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
#6649 0x34b7f7c0 in -[UIApplication handleEvent:withNewEvent:]
#6650 0x34b7eebc in -[UIApplication sendEvent:]
#6651 0x34b7e7f0 in _UIApplicationHandleEvent
#6652 0x33910ee4 in PurpleEventCallback
#6653 0x322352b2 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
#6654 0x322371dc in __CFRunLoopDoSource1
#6655 0x32238194 in __CFRunLoopRun
#6656 0x321df0c2 in CFRunLoopRunSpecific
#6657 0x321defd0 in CFRunLoopRunInMode
#6658 0x34b0ab20 in -[UIApplication _run]
#6659 0x34b08fc0 in UIApplicationMain
#6660 0x000026f8 in main at main.m:14
值得注意的是,如果我尝试基于单击事件播放电影的代码,它几乎就像应用程序尚未完成与窗口有关的“连接”操作。以前有人遇到过这样的事情吗?
I'm trying to use MPMoviePlayerController
in a fairly simple iPhone app. The basic layout is an UIApplicationDelegate
associated with a UIWindow
xib file. Within the applicationDidFinishLaunching
method, I'm trying to play a movie with the following code:
// Path to the movie
NSString *path = [[NSBundle mainBundle] pathForResource:@"logoscreen" ofType:@"m4v"];
movieURL = [NSURL fileURLWithPath:path];
// Setup the player
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
// Use the new 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleNone;
moviePlayer.shouldAutoplay = YES;
[window addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
When this executes, I get an "EXC_BAD_ACCESS" error, and the GDB loads a huge stack (with the "_makeSubtreePerformSelector" method repeating several thousand times:
#6633 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6634 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6635 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6636 0x34b0cb0c in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:]
#6637 0x34b0c9c4 in -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:]
#6638 0x34b0c790 in -[UIView(Internal) _addSubview:positioned:relativeTo:]
#6639 0x34b0c408 in -[UIView(Hierarchy) addSubview:]
#6640 0x33f81928 in -[MPInlineVideoViewController _transitionToFullscreenAnimated:]
#6641 0x33f7df5c in -[MPInlineVideoViewController setFullscreen:animated:]
#6642 0x33f05998 in -[MPMoviePlayerControllerNew setFullscreen:animated:]
#6643 0x33f059cc in -[MPMoviePlayerControllerNew setFullscreen:]
#6644 0x33f06b2c in -[MPMoviePlayerController setFullscreen:]
#6645 0x00002ab0 in -[GiyapLiteAppDelegate playMovie:] at GiyapLiteAppDelegate.m:67
#6646 0x000028a2 in -[GiyapLiteAppDelegate applicationDidFinishLaunching:] at GiyapLiteAppDelegate.m:38
#6647 0x34b16154 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:]
#6648 0x34cc46d4 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
#6649 0x34b7f7c0 in -[UIApplication handleEvent:withNewEvent:]
#6650 0x34b7eebc in -[UIApplication sendEvent:]
#6651 0x34b7e7f0 in _UIApplicationHandleEvent
#6652 0x33910ee4 in PurpleEventCallback
#6653 0x322352b2 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
#6654 0x322371dc in __CFRunLoopDoSource1
#6655 0x32238194 in __CFRunLoopRun
#6656 0x321df0c2 in CFRunLoopRunSpecific
#6657 0x321defd0 in CFRunLoopRunInMode
#6658 0x34b0ab20 in -[UIApplication _run]
#6659 0x34b08fc0 in UIApplicationMain
#6660 0x000026f8 in main at main.m:14
It's worth noting that if I try the code that plays the movie based on a click event, it works just fine. It's almost like the application hasn't finished "wiring" something up yet in regards to the window hierarchy? Has anyone encountered anything like this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您应该尝试将
animated
设置为 No。Maybe you should try setting
animated
to No.