我正在尝试在一个相当简单的iPhone应用中使用MPMoviePlayerController
。基本布局是与UIApplicationDelegate
xib文件关联的UIWindow
。在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
值得注意的是,如果我尝试基于点击事件播放电影的代码,它就可以正常工作。这几乎就像应用程序尚未完成关于窗口层次结构的“连接”一些东西?有没有人遇到过这样的事情?
答案 0 :(得分:0)
也许您应该尝试将animated
设置为否。