用视频做启动页

- (void) showStartMedia{

    NSString *path = [[NSBundle mainBundle] pathForResource:@"loadingVedio3" ofType:@"m4v"];
    NSURL *url = [NSURL fileURLWithPath:path];
    _mediaVC = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
    
    CGRect rect = [[UIScreen mainScreen] bounds];
    _mediaVC.view.frame = rect;
    _mediaVC.moviePlayer.controlStyle = MPMovieControlStyleNone;
    _mediaVC.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
    [self.view addSubview:_mediaVC.view];
    
    if ([_mediaVC.moviePlayer respondsToSelector:@selector(prepareToPlay)])
    {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopPlayerCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:_mediaVC.moviePlayer];
    }
}

- (void) stopPlayerCallback:(id)sender
{
    _mediaVC.view.alpha = 1.;
    [UIView beginAnimations:@"MEDIA" context:nil];
    [UIView setAnimationDuration:0.85];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(OnStoped)];
    _mediaVC.view.alpha = 0.;
    [UIView commitAnimations];
    
    //
    [self loadingViewDidDone];
}

- (void)OnStoped
{
    [_mediaVC.view removeFromSuperview];
    _mediaVC = nil;
}

- (void) loadingViewDidDone{
    
    if (self.loadingVCBlock !=nil) {
        
        [self loadingVCBlock]();
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

 

你可能感兴趣的:(用视频做启动页)