MPMoviePlayerViewController掐了全屏

MPMoviePlayerViewController掐了全屏

问题描述:

我有搜索网站上,但像我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)

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);