Iphone MPMoviePlayer控制风格

Iphone MPMoviePlayer控制风格,iphone,objective-c,mpmovieplayercontroller,Iphone,Objective C,Mpmovieplayercontroller,我想用以下代码对MPMoviePlayer隐藏控件: -(IBAction)video:(id)sender { NSBundle *bundle = [NSBundle mainBundle]; NSString *moviePath = [bundle pathForResource:@"Intro" ofType:@"mov"]; NSURL *movie = [NSURL fileURLWithPath:moviePath]; MPMoviePlayerController *con

我想用以下代码对MPMoviePlayer隐藏控件:

-(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];  }
但是那不行。

你试过这个吗
[videoplayerbj setControlStyle:MPMovieControlStyleNone]

您正在重复代码。MPMoviePlayerController具有MPMoviePlayerController。因此,将其用作
movieplayervc.moviePlayer.controlStyle=MPMovieControlStyleNone

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

stream.view.hidden = YES;

希望这有帮助

使用此代码,您可以播放视频、停止视频并从自定义视图中删除。而
MPMoviePlayerController
是电影播放器。 希望这对你有用。谢谢

 -(void)playMovie:(id)sender {

        UIButton *buttonThatWasPressed = (UIButton *)sender;
        buttonThatWasPressed.enabled = NO;
        NSString * str=[[NSBundle mainBundle]pathForResource:@"yo2" ofType:@"mov"];
        NSURL * url=[NSURL fileURLWithPath:str];
        MPMoviePlayerController * movieController=[[MPMoviePlayerController alloc]initWithContentURL:url];
        movieController.controlStyle=MPMovieControlStyleFullscreen;
        [movieController.view setFrame:self.view.bounds];
        [self.view addSubview:movieController.view];
        [movieController prepareToPlay];
        [movieController play];
        _moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:url];
        [[NSNotificationCenter defaultCenter] addObserver:self
                                   selector:@selector(moviePlayBackDidFinish:)
                                   name:MPMoviePlayerPlaybackDidFinishNotification
                                   object:_moviePlayer];

       [[NSNotificationCenter defaultCenter] addObserver:self 
                                   selector:@selector(moviePlayBackDonePressed:)
                                   name:MPMoviePlayerDidExitFullscreenNotification 
                                   object:_moviePlayer];

       _moviePlayer.controlStyle = MPMovieControlStyleDefault;
       _moviePlayer.shouldAutoplay = YES;
       [self.view addSubview:_moviePlayer.view];
       [_moviePlayer setFullscreen:YES animated:YES]; }
当您的视频或电影从用户处停止或视频播放已完成时,将调用此方法

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


}

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