arkader

MPMoviePlayerController exemple

Jul 23rd, 2013
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(void)playMovie
  2. {
  3.     NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"CHLOE_T2T_010713_MODIFIER_V2" ofType:@"mp4"]];
  4.    
  5.     self.moviePlayer =  [[MPMoviePlayerController alloc]
  6.                      initWithContentURL:url];
  7.    
  8.    
  9.     [[NSNotificationCenter defaultCenter] addObserver:self
  10.                                              selector:@selector(moviePlayBackDidFinish:)
  11.                                                  name:MPMoviePlayerPlaybackDidFinishNotification
  12.                                                object:self.moviePlayer];
  13.    
  14.     self.moviePlayer.controlStyle = MPMovieControlStyleDefault;
  15.    
  16.     self.moviePlayer.shouldAutoplay = YES;
  17.    
  18.     [self.view addSubview:self.moviePlayer.view];
  19.     [self.moviePlayer setFullscreen:YES animated:YES];
  20.    
  21. }
  22.  
  23. - (void) moviePlayBackDidFinish:(NSNotification*)notification {
  24.     NSLog(@"fin video");
  25.     MPMoviePlayerController *player = [notification object];
  26.     [[NSNotificationCenter defaultCenter]
  27.      removeObserver:self
  28.      name:MPMoviePlayerPlaybackDidFinishNotification
  29.      object:player];
  30.    
  31.     if ([player
  32.          respondsToSelector:@selector(setFullscreen:animated:)])
  33.     {
  34.         [player.view removeFromSuperview];
  35.     }
  36.    
  37.     //self.viewDeckController.rotationEnabled = YES;
  38.    
  39.     UIViewController *controller = [[UIViewController alloc] init];
  40.     [self.viewDeckController.navigationController presentViewController:controller animated:NO completion:nil];
  41.     [controller release];
  42. }
Add Comment
Please, Sign In to add comment