我在我的应用程序中使用了 MPMoviePlayerController。
我得到了正确的 URL,但 MPMoviePlayer 不播放视频,它只显示黑屏。
我的代码如下:
[video setImage:[UIImage imageNamed:@"video_active.png"] forState:UIControlStateNormal];
NSString *filename=[NSString stringWithFormat:@"%@.mp4",[appdel.TempVideoUrl valueForKey:tag]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:filename];
NSURL *movieURL = [NSURL fileURLWithPath:filePath] ;
theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.view.frame = CGRectMake(106, 18, 216, 235);
[uploadview addSubview:theMovie.view];
// Play the movie.
[theMovie pause];
我得到这样的 URL:file://localhost/var/mobile/Applications/6E1D4CB7-A08D-438B-9FE7-E2FD9B7B5EEC/Documents/136_1355227629.mp4