MPMoviePlayer controlStyle

后端 未结 4 735
情话喂你
情话喂你 2021-01-21 10:54

I want to hide the controls from the MPMoviePlayer with this code:

-(IBAction)video:(id)sender {

NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath =         


        
相关标签:
4条回答
  • 2021-01-21 11:25

    have you tried this [videoPlayerobj setControlStyle:MPMovieControlStyleNone];

    0 讨论(0)
  • 2021-01-21 11:28

    My player is set up in the viewDidLoad and this line hides the MPMoviePlayerController. I have intialised my MPMoviePlayer controller as *stream.

    stream.view.hidden = YES;
    

    Hope this helps!

    0 讨论(0)
  • 2021-01-21 11:34

    You are repeating code. MPMoviePlayerViewController has MPMoviePlayerController. So use it as movieplayervc.moviePlayer.controlStyle = MPMovieControlStyleNone;

    0 讨论(0)
  • 2021-01-21 11:38

    You can play video and stop video and remove from your custom view with this code. and MPMoviePlayerController is movie player. Hope this is useful for you.thank you

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

    This method is called when your video or movie is stop from user or video playback has finish.

     -(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 讨论(0)
提交回复
热议问题