MoviePlayerViewController转换导致崩溃

时间:2010-06-26 22:03:59

标签: iphone

我一直在试图解决这个问题 - 我正在使用MoviePlayerViewController播放一些视频,但是当我试图通过加速度计摇动播放随机视频时,我试图切换到新电影。

以下是播放电影的代码:

            -(void)playMovieAtURL:(NSURL*)theURL { 
         MPMoviePlayerViewController* theMovie=[[MPMoviePlayerViewController alloc] initWithContentURL:theURL]; 

          if (theMovie){
         [self presentMoviePlayerViewControllerAnimated:theMovie];
          theMovie.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
         [theMovie.moviePlayer play];
         [theMovie release]; 
    }
}

这是加速计代码:

- (void) accelerometer: (UIAccelerometer *)accelerometer didAccelerate: (UIAcceleration *)acceleration {
if (self.lastAcceleration) {
    if (!shakeDetected && IsDeviceShaking(self.lastAcceleration, acceleration, 0.7)) {
        shakeDetected = YES; 


NSLog(@"Shake detected"); 

   int filescount = [entries count];
   int randomIndex;

   for( int index = 0; index < filescount; index++ )
   {
    randomIndex= arc4random() % filescount;
    [entries exchangeObjectAtIndex:index withObjectAtIndex:randomIndex];
   }

   AppRecord *app = [entries objectAtIndex:randomIndex];
   contentController.detailItem = app;
   [self playMovieAtURL:[NSURL URLWithString:app.applink]]; 
  }
  else if (shakeDetected && !IsDeviceShaking(self.lastAcceleration, acceleration, 0.2)) {
            shakeDetected = NO;
        }
    }
 self.lastAcceleration = acceleration;
}

在此位置切换视频时发生崩溃:

[self presentMoviePlayerViewControllerAnimated:theMovie];

我动摇更改视频时的调试器错误是:

由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'正在进行转换时,尝试开始从UINavigationController到MPMoviePlayerViewController的模式转换。等待viewDidAppear / viewDidDisappear知道当前转换已完成'

非常感谢任何建议和想法。谢谢!!

1 个答案:

答案 0 :(得分:0)

我第一次在设备上安装我的应用时遇到了类似的问题。当我尝试播放视频时,应用程序崩溃了。我也在使用 [self presentMoviePlayerViewControllerAnimated:theMovieView];呼叫。 这是调试器的堆栈转储。

#0  0x3037fd7c in ___forwarding___
#1  0x30312680 in __forwarding_prep_0___
#2  0x35203dee in -[MPMoviePlayerViewController viewDidAppear:]
#3  0x324128bc in -[UIWindowController transitionViewDidComplete:fromView:toView:]
#4  0x323959da in -[UITransitionView notifyDidCompleteTransition:]
#5  0x3239588e in -[UITransitionView _didCompleteTransition:]
#6  0x32412556 in -[UITransitionView _transitionDidStop:finished:]
#7  0x3237a97a in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
#8  0x3237a884 in -[UIViewAnimationState animationDidStop:finished:]
#9  0x343557c0 in run_animation_callbacks
#10 0x34355662 in CA::timer_callback
#11 0x30352a5a in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#12 0x30354ee4 in __CFRunLoopDoTimer
#13 0x30355864 in __CFRunLoopRun
#14 0x302fe8ea in CFRunLoopRunSpecific
#15 0x302fe7f2 in CFRunLoopRunInMode
#16 0x31a776ee in GSEventRunModal
#17 0x31a7779a in GSEventRun
#18 0x323272a6 in -[UIApplication _run]
#19 0x32325e16 in UIApplicationMain
#20 0x000022ca in main at main.m:14