What is wrong with this code?
{
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 mo开发者_如何学JAVAviePlayer];
[player play];
}
It will play videos from a local file, but the same file on a server doesn't play. Instead it returns this error:
2010-08-07 13:38:36.229 Fashion[47473:207] video = http://gravuremag.com/ssp_director/albums/album-54/lg/KIKI___NYM_NAME_SLATE.mp4 2010-08-07 13:38:36.314 Fashion[47473:207] NSConcreteNotification 0xae175b0 {name = MPMoviePlayerPlaybackDidFinishNotification; object = ; userInfo = { MPMoviePlayerPlaybackDidFinishReasonUserInfoKey = 1; error = Error Domain=MediaPlayerErrorDomain Code=2 UserInfo=0xae172b0 "This movie could not be played."; }}
I ran into this very same problem and came here looking for help. Well, turns out I found the answer myself! In my case, the filename I was calling was incorrect. Rather than giving me a "File not found" error message, it was giving the very message you received. My file was saved locally and used the time as part of the filename. While it saved in one second, the filename was stored in the next second, giving an incorrect filename.
No doubt your problem is long-solved, but for others in the future, if you get this error, double-check your filename!
精彩评论