Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- if (selectedBool) {
- timer = [NSTimer
- scheduledTimerWithTimeInterval:1.0
- target:self
- selector:@selector(timedJob)
- userInfo:nil
- repeats:YES];
- [timer fire];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerPlaybackStateDidChange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
- NSString * videoStr = [NSString stringWithFormat:@"%@/%@", gameVideoURL , videoUrlStr];
- NSString * urlStrEscaped = [videoStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- NSURL * dataURL = [NSURL URLWithString:urlStrEscaped];
- moviePlayerCrl.movieSourceType = MPMovieSourceTypeStreaming;
- moviePlayerCrl = [[MPMoviePlayerController alloc] initWithContentURL:dataURL];
- [self registerForMovieNotifications];
- }
- }
- - (void)registerForMovieNotifications
- {
- //movie is ready to play notifications
- if ([self.moviePlayerCrl respondsToSelector:@selector(loadState)])
- {
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
- [self.moviePlayerCrl prepareToPlay];
- }
- //movie has finished notification
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
- }
- - (void)moviePlayerLoadStateChanged:(NSNotification*)notification
- {
- NSLog(@"load state changed");
- //unless state is unknown, start playback
- if ([self.moviePlayerCrl loadState] != MPMovieLoadStateUnknown)
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
- [self.moviePlayerCrl.view setFrame: CGRectMake(0,
- [UIApplication sharedApplication].statusBarFrame.size.height
- + self.navigationController.navigationBar.frame.size.height
- + self.navigationController.toolbar.frame.size.height,
- self.view.bounds.size.width,
- self.view.bounds.size.height
- - [UIApplication sharedApplication].statusBarFrame.size.height
- - self.navigationController.navigationBar.frame.size.height
- - self.navigationController.toolbar.frame.size.height
- - self.tabBarController.tabBar.frame.size.height
- )]; // x, y, width, height
- [self.view addSubview:self.moviePlayerCrl.view];
- [self.view bringSubviewToFront:self.moviePlayerCrl.view];
- [self.moviePlayerCrl setFullscreen:NO animated:YES];
- [self.moviePlayerCrl play];
- [moviePlayerCrl setCurrentPlaybackTime:startPlaybackTime];
- }
- }
- -(void)didselectVid:(VideoClipData *)vid
- {
- videoUrlStr = vid.evtUrlStr;
- startTime = vid.evtStartStr;
- endTime = vid.evtEndTimeStr;
- gameNamesStr = vid.evtNameStr;
- double startTimeInterval = [startTime doubleValue];
- double endTimeInterval = [endTime doubleValue];
- startPlaybackTime = startTimeInterval;
- endPlaybackTime = endTimeInterval;
- selectedBool = YES;
- [self viewDidLoad];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement