2013-02-18 51 views
2

背景圖像是動畫天空的MPMoviePlayerController - 黑色畫面切換時的觀點

當設置頁面(靜態圖像)和主頁(動畫圖像)的屏幕的動畫經常脫落,併成爲一個單一的黑色圖像之間的切換

有人可以提出一個理由或解決方案嗎?

謝謝!

亨利彩色視覺應用

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.mp = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"iPhone4" ofType:@"mov"]]]; 
    mp.repeatMode = MPMovieRepeatModeOne; 
    [mp.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    mp.scalingMode = MPMovieScalingModeFill; 
    [mp setFullscreen:YES]; 
    mp.controlStyle = MPMovieControlStyleNone; 
    [self.view addSubview:mp.view]; 
    [self.view sendSubviewToBack:mp.view]; 
    [mp prepareToPlay]; 
} 

- (void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 

    [self.mp play]; 
} 
+0

你可以張貼截圖或開關 – Warewolf 2013-02-18 08:22:54

+0

一些細節https://www.dropbox.com/ s/jg7169bc5ron3qp/BLACK%20SCREEN%20iP5.PNG – TurtleKurtze 2013-02-18 08:27:36

+0

我通過Dropbox添加了照片鏈接。謝謝。亨利 – TurtleKurtze 2013-02-18 08:27:55

回答

0

嘗試觀察者添加到您的播放器。就像這樣:

- (void)viewDidLoad 
{ 
    ///... 
    self.mp = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"iPhone4" ofType:@"mov"]]]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlaybackComplete:) 
               name:MPMoviePlayerPlaybackDidFinishNotification 
              object:self.mp]; 
    ///... 
} 

然後你就可以得到了什麼問題:

- (void)moviePlaybackComplete:(NSNotification *)notification 
{ 
    NSLog(@"Movie Finished."); 

    int reason = [[[notification userInfo] valueForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey] intValue]; 
    if (reason == MPMovieFinishReasonPlaybackError) { 
     NSDictionary *notificationUserInfo = [notification userInfo]; 
     NSError *mediaPlayerError = [notificationUserInfo objectForKey:@"error"]; 
     if (mediaPlayerError) 
     { 
     NSLog(@"playback failed with error description: %@", [mediaPlayerError localizedDescription]); 
     } 
     else 
     { 
     NSLog(@"playback failed without any given reason"); 
     } 
    }  

    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:self.mp]; 

}