daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import <UIKit/UIKit.h>
  2. #import <MediaPlayer/MediaPlayer.h>  
  3.  
  4. @interface BigBuckBunnyViewController : UIViewController {
  5.  
  6. }
  7.  
  8. -(IBAction)playMovie:(id)sender;
  9.  
  10. @end
  11.    
  12. #import "BigBuckBunnyViewController.h"
  13.  
  14. @implementation BigBuckBunnyViewController
  15.  
  16. -(IBAction)playMovie:(id)sender
  17. {
  18. UIButton *playButton = (UIButton *) sender;
  19.  
  20. NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"ladder rack 1 4"  
  21. ofType:@"m4v"];
  22. NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
  23. MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc]
  24. initWithContentURL:fileURL];
  25.  
  26. [[NSNotificationCenter defaultCenter] addObserver:self
  27.  
  28. selector:@selector(moviePlaybackComplete:)
  29.  
  30. name:MPMoviePlayerPlaybackDidFinishNotification
  31.  
  32. object:moviePlayerController];
  33.  
  34. [moviePlayerController.view setFrame:CGRectMake(playButton.frame.origin.x,
  35.  
  36. playButton.frame.origin.y,
  37.  
  38. playButton.frame.size.width,
  39.  
  40. playButton.frame.size.height)];
  41.  
  42. [self.view addSubview:moviePlayerController.view];
  43. //moviePlayerController.fullscreen = YES;
  44.  
  45. //moviePlayerController.scalingMode = MPMovieScalingModeFill;
  46.  
  47. [moviePlayerController play];
  48. }
  49.  
  50. - (void)moviePlaybackComplete:(NSNotification *)notification
  51. {
  52. MPMoviePlayerController *moviePlayerController = [notification object];
  53. [[NSNotificationCenter defaultCenter] removeObserver:self
  54.  
  55. name:MPMoviePlayerPlaybackDidFinishNotification
  56.  
  57. object:moviePlayerController];
  58.  
  59. [moviePlayerController.view removeFromSuperview];
  60. [moviePlayerController release];
  61. }
  62.  
  63. - (void)dealloc {
  64. [super dealloc];
  65. }
  66.  
  67. @end
  68.    
  69. NSURL   *fileURL    =   [NSURL fileURLWithPath:filepath] absoluteString];
  70.    
  71. #import <UIKit/UIKit.h>
  72. #import <MediaPlayer/MediaPlayer.h>
  73.  
  74. @interface TipsViewController : UIViewController {
  75.  
  76.   MPMoviePlayerViewController *playerController;
  77. }
  78.  
  79. -(IBAction)playVideo;
  80.  
  81. @end
  82.    
  83. - (IBAction)playVideo{
  84.  
  85.  NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"tcniche"  
  86.     ofType:@"mp4"]];
  87.  
  88.  if(url != nil){
  89.  
  90.            playerController = [[MPMoviePlayerViewController alloc]
  91.     initWithContentURL:url];
  92.            [self presentMoviePlayerViewControllerAnimated:playerController];
  93.  
  94.            playerController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
  95.  
  96.           [playerController.moviePlayer play];
  97.  }
  98.  else{
  99.  
  100.       NSLog(@"URL not found");
  101.  
  102.     }
  103.  
  104.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top