2010-11-10 53 views
0

我有搜索網站上,但像我MPMoviePlayerViewController掐了全屏

當我做了捏放我的視頻,到通知「MPMoviePlayerPlaybackDidFinishNotification」叫我還沒有發現同樣的問題。

之後,「完成」按鈕,就可把視頻在暫停和播放器的工作原理很糟糕......

我不明白爲什麼這個通知被稱作......

這是我的代碼

- (id) init 
{ 
    self = [super init]; 

    movie=[[MPMoviePlayerViewController alloc] init]; 
    //we init the frame here and after the view rotate the video 
    [movie.view setFrame: CGRectMake(0, 0, 1024,768)]; 

    return self; 
} 

+ (MoviePlayerManager*) getInstance 
{ 

    static MoviePlayerManager *movieSingleton; 

    if (movieSingleton==nil) 
    { 
     movieSingleton = [[MoviePlayerManager alloc]init]; 

    } 

    return movieSingleton; 

} 

- (void) load:(NSURL*) a_videoFile withType:(VideoType)a_type 
{ 

    type = a_type; 

    [movie.moviePlayer setContentURL:a_videoFile]; 

     switch (type) { 
     case VT_INTRO: 
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallbackIntro:) name:MPMoviePlayerPlaybackDidFinishNotification object:movie.moviePlayer]; 
      break; 

     case VT_RESPONSE: 
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallbackResponse:) name:MPMoviePlayerPlaybackDidFinishNotification object:movie.moviePlayer]; 
      break; 

     default: 
      NSLog(@"video Type not initialised"); 
      break; 
    } 

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieIsReadyToPlay:) name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification object:movie.moviePlayer]; 


    [movie.moviePlayer prepareToPlay]; 


} 


-(void)myMovieIsReadyToPlay:(NSNotification*)aNotification 
{ 
    [gsDelegate.view addSubview:movie.view]; 
    [movie.moviePlayer play]; 

    movie.moviePlayer.controlStyle = MPMovieControlStyleFullscreen; 

} 

- (void) myMovieFinishedCallbackIntro:(NSNotification*)aNotification 
{ 
    NSNumber* reason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]; 

    NSLog(@"%d",reason); 

    if(aNotification != nil) 
    { 

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

     [gsDelegate movieIntroDidStop]; 

    } 
} 

NSNumber* reason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];

是出或當我按下 「完成」

捏相同

THX對您有所幫助(和我的英語不好對不起; OP)

回答

0
NSNumber* reason = [[aNotification userInfo] objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey]; 
NSLog(@"%d",reason); 

的NSNumber是一個Objective-C的對象,而不是原始的C類型。您正在顯示指向該對象的指針,而不是值。

糾正:

NSLog(@"%@", reason); 

或更改原因爲Integer:

int reason = [[userInfo objectForKey:@"MPMoviePlayerPlaybackDidFinishReasonUserInfoKey"] intValue]; 
NSLog(@"%d", reason);