Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. - (void)viewDidLoad
  2. {
  3. [super viewDidLoad];
  4.  
  5. if (selectedBool) {
  6.  
  7. timer = [NSTimer
  8. scheduledTimerWithTimeInterval:1.0
  9. target:self
  10. selector:@selector(timedJob)
  11. userInfo:nil
  12. repeats:YES];
  13. [timer fire];
  14.  
  15. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
  16. NSString * videoStr = [NSString stringWithFormat:@"%@/%@", gameVideoURL , videoUrlStr];
  17. NSString * urlStrEscaped = [videoStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  18. NSURL * dataURL = [NSURL URLWithString:urlStrEscaped];
  19. moviePlayerCrl.movieSourceType = MPMovieSourceTypeStreaming;
  20. moviePlayerCrl = [[MPMoviePlayerController alloc] initWithContentURL:dataURL];
  21.  
  22. [self registerForMovieNotifications];
  23. }
  24. }
  25.  
  26. - (void)registerForMovieNotifications
  27. {
  28. //movie is ready to play notifications
  29. if ([self.moviePlayerCrl respondsToSelector:@selector(loadState)])
  30. {
  31. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
  32.  
  33. [self.moviePlayerCrl prepareToPlay];
  34. }
  35. //movie has finished notification
  36. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
  37. }
  38.  
  39. - (void)moviePlayerLoadStateChanged:(NSNotification*)notification
  40. {
  41. NSLog(@"load state changed");
  42.  
  43. //unless state is unknown, start playback
  44. if ([self.moviePlayerCrl loadState] != MPMovieLoadStateUnknown)
  45. {
  46. [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
  47.  
  48.  
  49. [self.moviePlayerCrl.view setFrame: CGRectMake(0,
  50.  
  51. [UIApplication sharedApplication].statusBarFrame.size.height
  52. + self.navigationController.navigationBar.frame.size.height
  53. + self.navigationController.toolbar.frame.size.height,
  54.  
  55. self.view.bounds.size.width,
  56.  
  57. self.view.bounds.size.height
  58. - [UIApplication sharedApplication].statusBarFrame.size.height
  59. - self.navigationController.navigationBar.frame.size.height
  60. - self.navigationController.toolbar.frame.size.height
  61. - self.tabBarController.tabBar.frame.size.height
  62.  
  63. )]; // x, y, width, height
  64.  
  65. [self.view addSubview:self.moviePlayerCrl.view];
  66. [self.view bringSubviewToFront:self.moviePlayerCrl.view];
  67. [self.moviePlayerCrl setFullscreen:NO animated:YES];
  68. [self.moviePlayerCrl play];
  69. [moviePlayerCrl setCurrentPlaybackTime:startPlaybackTime];
  70. }
  71. }
  72.  
  73.  
  74. -(void)didselectVid:(VideoClipData *)vid
  75. {
  76. videoUrlStr = vid.evtUrlStr;
  77. startTime = vid.evtStartStr;
  78. endTime = vid.evtEndTimeStr;
  79. gameNamesStr = vid.evtNameStr;
  80.  
  81. double startTimeInterval = [startTime doubleValue];
  82. double endTimeInterval = [endTime doubleValue];
  83. startPlaybackTime = startTimeInterval;
  84. endPlaybackTime = endTimeInterval;
  85.  
  86. selectedBool = YES;
  87.  
  88. [self viewDidLoad];
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement