0

我正在使用 MpMovieplayer 在 ios 5 中动态播放 mov 文件(从设备中选择视频),但它没有播放。它显示黑屏。我也尝试直接将电影 url 提供给播放器,但它不起作用。有没有播放器而不是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];
 }
4

2 回答 2

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];
}    
于 2012-10-08T17:38:38.460 回答
0

你应该看看 AVPlayer 类。

MPMoviePlayerController 实际上是从 AVPlayer 类“派生”的,因此可以使其工作。

于 2012-10-08T17:39:34.200 回答