0

我想知道如何添加一個轉換(當視頻開始時淡入淡出,視頻結束時淡出)。moviePlayBackDidFinish和Transition的效果

你能幫他完成這項任務,我有點失去了轉型,從來沒有與它之前播放/:

這裏是我的代碼

- (void) startSlideShow 
{ 
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
             pathForResource:@"2" ofType:@"mov"]]; 


    MPMoviePlayerController *moviePlayer = 
    [[MPMoviePlayerController alloc] initWithContentURL:url]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlayBackDidFinish:) 
               name:MPMoviePlayerPlaybackDidFinishNotification 
               object:moviePlayer]; 
    moviePlayer.view.frame = CGRectMake(0, 0, 768, 1024); 

    moviePlayer.controlStyle = MPMovieControlStyleDefault; 
    moviePlayer.shouldAutoplay = YES; 
    [self.view addSubview:moviePlayer.view]; 
    [moviePlayer setFullscreen:YES animated:YES]; 
    } 


-(void)moviePlayBackDidFinish: (NSNotification*)notification 
{ 
    MPMoviePlayerController *moviePlayer = [notification object]; 

    [[NSNotificationCenter defaultCenter] removeObserver:self  
                name:MPMoviePlayerPlaybackDidFinishNotification 
                object:moviePlayer]; 

    if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) 
    { 
     // the transition should be around here... (fade out) 
     [moviePlayer.view removeFromSuperview]; 
    } 
    [moviePlayer release]; 

    [self checkResources]; 
} 

回答

0

你可以捕捉的屏幕截圖你的UI在播放電影之前。

UIGraphicsBeginImageContext(view.frame.size); 
[view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *screenshotOfView = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

比你把你的MoviePlayer比你添加圖片作爲的UIImageView在此基礎之上(例如,[[UIApplication的sharedApplication] keyWindow])。比你淡出圖像。

(我不知道你是否也可以動畫從0-1 moviePlayer.view.alpha)。

基本淡入/淡出可以通過動畫的alpha值來實現:

view.alpha = 0.0; 
[UIView animateWithDuration: 0.35 animations:^{ 
    view.alpha = 1.0; 
}]; 
+0

我不明白這一點......我想它是什麼/淡出效果應用淡入時,視頻/圖像即將開始。感謝幫助我的男人! – user1256827 2012-03-09 10:47:25

+0

通過爲alpha值設置動畫可以實現基本的淡入/淡出。我會編輯我的答案。 – calimarkus 2012-03-09 11:03:49