此代码有什么问题?
{
NSString *s = [urls objectAtIndex:selectedPage];
NSLog(@"video = %@\n", s); // JT 10.07.31
theMoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath: s]];
//? theMoviePlayer.scalingMode=MPMovieScalingModeAspectFill;
[self.view addSubview:theMoviePlayer.view];
//[theMoviePlayer play]; // Movie playback is asynchronous, so this method returns immediately.
//[self presentMoviePlayerViewControllerAnimated:theMoviePlayer]; // JT 10.08.07
//---play movie---
MPMoviePlayerController *player = [theMoviePlayer moviePlayer];
[player play];
}
它将播放本地文件中的视频,但服务器上的同一文件无法播放。相反,它会返回此错误:
2010-08-07 13:38:36.229时尚[47473:207]视频= http://gravuremag.com/ssp_director/albums/album-54/lg/KIKI___NYM_NAME_SLATE.mp4 2010-08-07 13:38:36.314时尚[47473:207] NSConcreteNotification 0xae175b0 {name = MPMoviePlayerPlaybackDidFinishNotification; object =; userInfo = { MPMoviePlayerPlaybackDidFinishReasonUserInfoKey = 1; error = Error Domain = MediaPlayerErrorDomain Code = 2 UserInfo = 0xae172b0“此电影无法播放。”; }}
答案 0 :(得分:0)
我遇到了同样的问题,来到这里寻求帮助。好吧,事实证明我自己找到了答案!就我而言,我调用的文件名不正确。它没有给我一个“找不到文件”错误消息,而是给出了收到的消息。我的文件已保存在本地,并将时间用作文件名的一部分。当它在一秒钟内保存时,文件名存储在下一秒,文件名不正确。
毫无疑问,您的问题已经解决了,但对于将来的其他人来说,如果您收到此错误,请仔细检查您的文件名!