如何使用动画在当前视图上添加MPMoviePlayerController

时间:2014-06-20 07:45:46

标签: ios ios7 mpmovieplayercontroller

我正在使用MPMoviePlayerController在我的iPad应用程序中播放视频。我使用下面的代码片段来添加要查看的电影播放器​​:

self.player =[[MPMoviePlayerController alloc] initWithContentURL: urlVideo];
[self.player prepareToPlay];
[self.player setMovieSourceType:MPMovieSourceTypeStreaming];
[self.player.view setBounds:CGRectMake(0, 0, 512, 374)];
if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
{
    NSLog(@"landscape..");
    [self.player.view setCenter:CGPointMake(512, 374)];
}
else{
    NSLog(@"portrait.");
    [self.player.view setCenter:CGPointMake(384, 502)];
}

self.player.controlStyle=MPMovieControlStyleEmbedded;
[self.player setScalingMode:MPMovieScalingModeAspectFit];
self.player.shouldAutoplay=YES;

[self.viewController.view addSubview: self.player.view];



self.btnCloseNormalMode= [UIButton buttonWithType:UIButtonTypeCustom];
[self.btnCloseNormalMode setImage:[UIImage imageNamed:@"close_button_icon.png"] forState:UIControlStateNormal];
[self.btnCloseNormalMode setFrame:CGRectMake(470, 5, 32, 32)];
[self.btnCloseNormalMode addTarget:self action:@selector(onSmallCloseBtnTap) forControlEvents:UIControlEventTouchUpInside];
[self.player.view addSubview:self.btnCloseNormalMode];

但是从上面的代码可以理解,它突然添加了视图。突然,视图上出现一个黑色视图,这对用户不友好。我们想要添加带有一些动画的电影播放器​​视图以使其流畅。我可以让电影播放器​​视图带有动画,如模态出现或任何合适的UIView动画。但我不知道动画。有人可以帮我这个!!!感谢。

0 个答案:

没有答案