2
我從我的iPhone照片庫檢索到電影文件,並將它們保存到我的應用程序的文檔目錄中。當我點擊一個電影文件時,我想用MPMoviePlayerController來播放它。不幸的是,它沒有播放這樣的錯誤的電影文件:MPMoviePlayerController失敗,itemFailedToPlayToEnd
_itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;
}
我已經搜索了很長時間來解決這個問題。有人說格式可能是不支持的。電影文件從照片庫中檢索,所以格式應該是OK的。另外,我將文件複製到NSBundle,MPMoviePlayerController可以播放它。所以文件是好的。以下是我的代碼:
NSString *newstr = [mFilePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
DLog(@"the raw is %@ the newstr is %@", mFilePath, newstr);
NSURL *url = [NSURL URLWithString:newstr];
DLog(@"the url is %@", url);
#if 0
NSBundle *bundle = [NSBundle mainBundle];
if (bundle) {
NSString *path = [bundle pathForResource:@"test" ofType:@"MOV"];
if (path) {
url = [NSURL fileURLWithPath:path];
DLog(@"the new url is %@", url);
}
}
#endif
mPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[mPlayer setMovieSourceType:MPMovieSourceTypeFile];
[mPlayer prepareToPlay];
[mPlayer.view setFrame:self.view.bounds];
[mPlayer play];
[self.view addSubview:mPlayer.view];
Can someone help me ? Thanks in advances!
得到相同的錯誤,但不是當我直接從服務器播放時... –