2012-10-08 85 views
0

我使用MpMovieplayer在ios 5中動態播放mov文件(選擇設備中的視頻),但它不是播放。它顯示blackscreen.I也嘗試直接給予播放器的電影網址,但它不起作用。是否有任何播放器而不是MPMovieplayer的提前打MOV files.Thanksmov文件的視頻播放器?

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

嘗試

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

你應該看看AVPlayer類。

MPMoviePlayerController實際上是從AVPlayer類派生出來的,所以可以使它工作。