MPMoviePlayer在设备上崩溃应用程序但不在模拟器中崩溃,但仅在尝试播放某些文件时

时间:2011-05-16 06:02:45

标签: mpmovieplayer

我正在编写一个使用MPMoviePlayer显示视频的应用程序,这些应用程序本地存储在设备上。当我尝试播放大部分视频时,应用程序会在设备上崩溃,但不会在模拟器上崩溃。我使用相同的代码播放所有视频,我尝试删除并重新安装应用程序,清理然后重新构建,没有运气。

模拟器是4.3版本,我正在测试应用程序的iPad版本是4.3.1。我正在使用Xcode 4

这是我用来播放其中一个崩溃视频的代码:

@implementation SinglePendulumControl

-(IBAction)playMovie:(id)sender  
{  
    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"SinglePendulumControl" ofType:@"mp4"];
    NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
    MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlaybackComplete:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayerController];

    [self.view addSubview:moviePlayerController.view];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
    [[self view] setBounds:CGRectMake(0, 0, 1024, 768)];
    [[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
    moviePlayerController.fullscreen = YES;
    [moviePlayerController play];
}  

- (void)moviePlaybackComplete:(NSNotification *)notification  
{  
    MPMoviePlayerController *moviePlayerController = [notification object];  
    [[NSNotificationCenter defaultCenter] removeObserver:self  
                                                    name:MPMoviePlayerPlaybackDidFinishNotification  
                                                  object:moviePlayerController];  

    [moviePlayerController.view removeFromSuperview];  
    [moviePlayerController release];  
}  

这是我用来播放其中一个没有崩溃的视频的代码:

@implementation GlueSettings

-(IBAction)playMovie:(id)sender  
{  
    NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"gluesettings" ofType:@"mp4"];
    NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
    MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlaybackComplete:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayerController];

    [self.view addSubview:moviePlayerController.view];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
    [[self view] setBounds:CGRectMake(0, 0, 1024, 768)];
    [[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
    moviePlayerController.fullscreen = YES;
    [moviePlayerController play];
}  

- (void)moviePlaybackComplete:(NSNotification *)notification  
{  
    MPMoviePlayerController *moviePlayerController = [notification object];  
    [[NSNotificationCenter defaultCenter] removeObserver:self  
                                                    name:MPMoviePlayerPlaybackDidFinishNotification  
                                                  object:moviePlayerController];  

    [moviePlayerController.view removeFromSuperview];  
    [moviePlayerController release];  
}  

崩溃的控制台日志:

May 16 17:55:31 unknown Vector[3590] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
    *** Call stack at first throw:
    (
        0   CoreFoundation                      0x33c3d64f __exceptionPreprocess + 114
        1   libobjc.A.dylib                     0x33f01c5d objc_exception_throw + 24
        2   CoreFoundation                      0x33c3d491 +[NSException raise:format:arguments:] + 68
        3   CoreFoundation                      0x33c3d4cb +[NSException raise:format:] + 34
        4   Foundation                          0x36da018f -[NSURL(NSURL) initFileURLWithPath:] + 70
        5   Foundation                          0x36da012f +[NSURL(NSURL) fileURLWithPath:] + 30
        6   Vector                              0x000eb7e5 -[BumpBarBumpSwitch playMovie:] + 80
        7   CoreFoundation                      0x33bad571 -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
        8   UIKit                               0x31f43ec9 -[UIApplication sendAction:to:from:forEvent:] + 84
        9   UIKit                               0x31f43e69 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
        10  UIKit                               0x31f43e3b -[UIControl sendAction:to:forEvent:] + 38
        11  UIKit                               0x31f43b8d -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
        12  UIKit                               0x31f44423 -[UIControl touchesEnded:withEvent:] + 342
        13  UIKit                               0x31f42bf5 -[UIWindow _sendTouchesForEvent:] + 368
        14  UIKit                               0x31f4256f -[UIWindow sendEvent:] + 262
        15  UIKit                               0x31f2b313 -[UIApplication sendEvent:] + 298
        16  UIKit                               0x31f2ac53 _UIApplicationHandleEvent + 5090
        17  GraphicsServices                    0x3257ee77 PurpleEventCallback + 666
        18  CoreFoundation                      0x33c14a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
        19  CoreFoundation                      0x33c1683f __CFRunLoopDoSource1 + 166
        20  CoreFoundation                      0x33c1760d __CFRunLoopRun + 520
        21  CoreFoundation                      0x33ba7ec3 CFRunLoopRunSpecific + 230
        22  CoreFoundation                      0x33ba7dcb CFRunLoopRunInMode + 58
        23  GraphicsServices                    0x3257e41f GSEventRunModal + 114
        24  GraphicsServices                    0x3257e4cb GSEventRun + 62
        25  UIKit                               0x31f55d69 -[UIApplication _run] + 404
        26  UIKit                               0x31f53807 UIApplicationMain + 670
        27  Vector                              0x000e9f31 main + 48
        28  Vector                              0x000e9efc start + 40
    )
May 16 17:55:31 unknown UIKitApplication:Vector-Systems.Vector[0xc457][3590] <Notice>: terminate called after throwing an instance of 'NSException'
May 16 17:55:31 unknown ReportCrash[3591] <Notice>: Formulating crash report for process Vector[3590]
May 16 17:55:31 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:Vector-Systems.Vector[0xc457]) Job appears to have crashed: Abort trap: 6
May 16 17:55:31 unknown SpringBoard[29] <Warning>: Application 'Vector' exited abnormally with signal 6: Abort trap: 6
May 16 17:55:31 unknown ReportCrash[3591] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/Vector_2011-05-16-175531_Duncans-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
May 16 17:55:34 unknown DTPower[3080] <Warning>: Task info failed for task Vector-Systems.Vector

0 个答案:

没有答案