Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. - (void)viewDidAppear:(BOOL)animated {
  2. [super viewDidAppear:animated];
  3.  
  4. [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
  5. [self becomeFirstResponder];
  6. }
  7.  
  8. - (void)viewWillDisappear:(BOOL)animated {
  9. [super viewWillDisappear:animated];
  10.  
  11.  
  12. [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
  13. [self resignFirstResponder];
  14. }
  15.  
  16.  
  17.  
  18.  
  19. - (void)Play_Video{
  20. [[AVAudioSession sharedInstance] setDelegate: self];
  21. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
  22. [[AVAudioSession sharedInstance] setActive: YES error: nil];
  23.  
  24.  
  25. self.movieController = [[MPMoviePlayerController alloc] init];
  26.  
  27. self.movieController.view.frame = self.view.bounds;
  28. self.movieController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
  29. self.movieController.backgroundView.backgroundColor = [UIColor clearColor];
  30. self.movieController.view.hidden = NO;
  31. self.movieController.controlStyle = MPMovieControlStyleEmbedded;
  32. [self.view addSubview:self.movieController.view];
  33. self.movieController.useApplicationAudioSession = NO;
  34.  
  35. [UrlBlock VideoURL:url success:^(NSURL *URL) {
  36.  
  37. if (self.movieController)
  38. self.movieController.contentURL = URL;
  39. else
  40. self.movieController = [[MPMoviePlayerController alloc] initWithContentURL:URL];
  41.  
  42. } failure:^(NSError *error) {
  43. [self performSelectorOnMainThread:@selector(Alert:) withObject:error waitUntilDone:NO];
  44. }];
  45.  
  46.  
  47. }
  48.  
  49. - (BOOL) canBecomeFirstResponder {
  50. return YES;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement