0
我一直在試圖解決這個問題 - 我正在用MoviePlayerViewController播放一些視頻,但當我試圖通過加速度計來播放隨機視頻時,我得到了一個崩潰試圖切換到新電影。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知道當前轉換已完成'
任何建議和想法,非常感謝。謝謝!!
您是否找到了解決此問題的方法(除了稍後調用某種方法的某些方法之外)? – stk 2012-12-20 15:46:44