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?