我正在使用MpMovieplayer在ios 5中动态播放mov文件(从设备中选择视频),但它没有播放。它显示blackscreen.I也尝试直接将电影网址提供给播放器,但它不起作用。是否有任何玩家而非MPMovieplayer播放mov文件。提前谢谢
NSString *path = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"mov"];
NSURL *movieURL = [NSURL fileURLWithPath:path];
NSLog(@"movieURL ----%@",movieURL);
movieplayer=[[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if([movieplayer respondsToSelector:@selector(view)])
{
movieplayer.controlStyle = MPMovieControlStyleFullscreen;
[movieplayer.view setFrame:self.view.bounds];
[self.view addSubview:movieplayer.view];
movieplayer.shouldAutoplay=true;
[movieplayer play];
}
答案 0 :(得分:0)
尝试
NSString *path = [[NSBundle mainBundle] pathForResource:@"your movie" ofType:@"mov"];
MPMoviePlayerViewController* tmpMoviePlayViewController=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
if (tmpMoviePlayViewController) {
tmpMoviePlayViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:tmpMoviePlayViewController animated:YES];
tmpMoviePlayViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieViewFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:tmpMoviePlayViewController];
[tmpMoviePlayViewController.moviePlayer play];
}
答案 1 :(得分:0)
你应该看一下AVPlayer类。
MPMoviePlayerController实际上是从AVPlayer类“派生”的,因此可以使它工作。