2012-02-13 29 views
0

我試圖得到一個的MPMoviePlayerController的工作,但有一個奇怪的問題,無限循環。當我點擊完成按鈕,似乎觸發了無限的外觀:的MPMoviePlayerController給出點按「完成」

2012-02-13 15:18:04.395 iDomsPortalDev [7376:12203] playbackFinished。 原因:用戶已退出2012-02-13 15:18:04.395 iDomsPortalDev [7376:12203] playbackFinished。原因:用戶已退出2012-02-13 15:18:04.395 iDomsPortalDev [7376:12203] playbackFinished。原因:用戶已退出

我用下面的通知上首發:

- (void) showMoviePlayer { 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullscreen:) name:MPMoviePlayerWillExitFullscreenNotification object:nil]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enteredFullscreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:nil]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];  

    id appDelegate = (iDomsAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    //[[self navigationController] presentMoviePlayerViewControllerAnimated:[appDelegate movieController]];  
    [[appDelegate moviePlayer].view setFrame: self.view.bounds]; 
    [self.view addSubview:[appDelegate moviePlayer].view]; 
    [[appDelegate moviePlayer] setFullscreen:YES animated:YES];  
} 

和下面的聽衆:

#pragma mark - Movieplayer feedback 
- (void)willEnterFullscreen:(NSNotification*)notification { 
    NSLog(@"willEnterFullscreen"); 
} 

- (void)enteredFullscreen:(NSNotification*)notification { 
    NSLog(@"enteredFullscreen"); 
} 

- (void)willExitFullscreen:(NSNotification*)notification { 
    NSLog(@"willExitFullscreen"); 
} 

- (void)exitedFullscreen:(NSNotification*)notification { 
    NSLog(@"exitedFullscreen"); 
    iDomsAppDelegate *appDelegate = (iDomsAppDelegate *)[[UIApplication sharedApplication] delegate];  
    [[appDelegate moviePlayer].view removeFromSuperview]; 
    [[appDelegate moviePlayer] release]; 
    [appDelegate setMovieController:nil]; 
    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
} 

- (void)playbackFinished:(NSNotification*)notification { 
    iDomsAppDelegate *appDelegate = (iDomsAppDelegate *)[[UIApplication sharedApplication] delegate];  
    NSNumber* reason = [[notification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]; 
    switch ([reason intValue]) { 
     case MPMovieFinishReasonPlaybackEnded: 
      NSLog(@"playbackFinished. Reason: Playback Ended");   
      break; 
     case MPMovieFinishReasonPlaybackError: 
      NSLog(@"playbackFinished. Reason: Playback Error"); 
      break; 
     case MPMovieFinishReasonUserExited: 
      NSLog(@"playbackFinished. Reason: User Exited"); 
      break; 
     default: 
      break; 
    } 
    [[appDelegate moviePlayer] setFullscreen:NO animated:YES]; 
} 

只有PlayBackFinished選擇器稱爲(無限次),所以有一定是愚蠢的東西我不

回答

0

我發現這個問題(與iOS5的模擬器中運行),它似乎公頃去過設置造成它的全屏選項:

[[appDelegate moviePlayer] setFullscreen:YES animated:YES]; 
相關問題