开发者

MPMoviePlayerViewController and pinch out for full screen

i have search on the site but i haven't find the same problem as mine

when i do a pinch out on my video, the notification "MPMoviePlayerPlaybackDidFinishNotification" is called.

after, the "done" button put the video in pause and the player works badly...

I don't understand why this notification is called...

this is my 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 addSubvie开发者_如何学Pythonw: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];

    }
}

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

is the same for a pinch out or when i press "done"

thx for your help (and sorry for my bad english ;op)


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

NSNumber is an Objective-C object, not a primitive C type. You are displaying the pointer to the object, not the value.

Correct with:

NSLog(@"%@", reason);

OR change reason to an Integer:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜