【问题标题】:Video players for mov files?mov文件的视频播放器?
【发布时间】:2012-10-08 17:25:51
【问题描述】:

我正在使用 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];
 }

【问题讨论】:

    标签: objective-c ios xcode mpmovieplayer


    【解决方案1】:

    试试

     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];
    }    
    

    【讨论】:

      【解决方案2】:

      你应该看看 AVPlayer 类。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-10
        • 1970-01-01
        相关资源
        最近更新 更多