2010-11-10 10 views
0

j'ai recherche sur le site, mais je l'ai pas trouvé le même problème que le mienMPMoviePlayerViewController et pincer pour plein écran

quand je fais une pincée sur ma vidéo, la notification « MPMoviePlayerPlaybackDidFinishNotification » est appelé.

après, le « fait » bouton mettre la vidéo en pause et le lecteur fonctionne mal ...

Je ne comprends pas pourquoi cette notification est appelée ...

c'est mon code

- (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]; 

    } 
} 

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

est le même pour un pincement ou lorsque je presse "fait"

thx pour votre aide (et désolé pour mon mauvais anglais; op)

Répondre

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

NSNumber est un objet Objective-C, pas un type primitif C. Vous affichez le pointeur sur l'objet, pas la valeur.

correcte avec:

NSLog(@"%@", reason); 

OU changer raison à un nombre entier:

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