2012-10-29 37 views
2

我想隐藏从MPMoviePlayer控件使用此代码:MPMoviePlayer controlStyle

-(IBAction)video:(id)sender { 

NSBundle *bundle = [NSBundle mainBundle]; 
NSString *moviePath = [bundle pathForResource:@"Intro" ofType:@"mov"]; 
NSURL *movie = [NSURL fileURLWithPath:moviePath]; 

MPMoviePlayerController *control = [[MPMoviePlayerController alloc]initWithContentURL:movie]; 
//[self.view addSubview: control.view]; 

control.scalingMode = MPMovieScalingModeFill; 
control.controlStyle = MPMovieControlStyleNone; 
control.shouldAutoplay = YES; 



[control play]; 

MPMoviePlayerViewController *movieplayer = [[MPMoviePlayerViewController alloc]initWithContentURL:movie]; 
[self presentMoviePlayerViewControllerAnimated:movieplayer]; } 

但是,这并不工作。

回答

0

你尝试过这个 [videoPlayerobj setControlStyle:MPMovieControlStyleNone];

+0

这不起作用 –

0

你重复的代码。 MPMoviePlayerViewController具有MPMoviePlayerController。因此,使用它作为movieplayervc.moviePlayer.controlStyle = MPMovieControlStyleNone;

0

我的播放器设置在viewDidLoad中,此行隐藏了MPMoviePlayerController。我已经初始化我的MPMoviePlayer控制器为*流。

stream.view.hidden = YES; 

希望这会有所帮助!

0

您可以使用此代码播放视频并停止视频并从您的自定义视图中移除。和MPMoviePlayerController是电影播放器​​。 希望这是you.thank有用你

当你的视频或电影是由用户或视频播放停止这种方法被称为具有结束。

-(void) moviePlayBackDonePressed:(NSNotification*)notification { 
     [_moviePlayer stop]; 
     [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerDidExitFullscreenNotification object:_moviePlayer]; 
     if ([_moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) 
     { 
       [_moviePlayer.view removeFromSuperview]; 
     } 
     _moviePlayer=nil; 
     [self dismissViewControllerAnimated:YES 
          completion:^{ 
           [self performSegueWithIdentifier:@"show" sender:self]; 
     }]; 
} 

- (void) moviePlayBackDidFinish:(NSNotification*)notification { // Remove observer 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                 name:MPMoviePlayerPlaybackDidFinishNotification 
               object:nil]; 

    [self dismissViewControllerAnimated:YES 
          completion:^{ 
           [self performSegueWithIdentifier:@"show" sender:self]; 
          }]; 


} 
+0

这是initialPlaybackTime的预期行为。我不知道任何推荐的解决方案,但您可以尝试将initialPlaybackTime设置为-1,并在视频开始播放后使用setCurrentPlaybackTime滚动到您希望播放开始的电影位置。 –