开发者

iOS: MPMoviePlayerController Done button doesn't work

I am adding an MPMoviePlayerController to a view like so:

player = [[MPMoviePlayerController alloc] initWithContentURL:url];
player.controlStyle = MPMovieControlStyleNone; 
[player.view setFrame:self.playerView.bounds];     
[self.playerView addSubview:player.view];

self.playerView is a small view inside my main view and I have custom buttons that control playback within that same main view. This all works fine.

I have a fullscreen button that works like so:

- (IBAction) btnFullScreenPressed:(id)sender {
    [player setFullscreen:TRUE animated:TRUE];
    [player setControlStyle:MPMovieControlStyleFullscreen];
}

This works fine, but then when I hit the Done button on the full screen controls, the movie stops playing but does not return to 开发者_开发问答the smaller self.playerView in my view. How can I get it to "un-fullscreen" and return to the smaller self.playerView?

Thanks.


Quite unintuitively you actually have to set the control style to default, i.e.:

- (IBAction) btnFullScreenPressed:(id)sender {
    [player setFullscreen:TRUE animated:TRUE];
    [player setControlStyle:MPMovieControlStyleDefault];
}

and, of course, then set it back to none when you receive MPMoviePlayerWillExitFullscreenNotification or MPMoviePlayerDidExitFullscreenNotification (I prefer "did exit").

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜