2012-10-29 36 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滾動到您希望播放開始的電影位置。 –