0

我不想全屏播放视频,是否可以在视图内播放视频?

这是我的代码。它确实创建了一个框架并在其中播放视频。问题是我不知道如何在屏幕上居中框架(它出现在屏幕的右侧)

截屏

NSBundle *bundle = [NSBundle mainBundle];
NSURL *url = [NSURL fileURLWithPath:[bundle pathForResource:@"movie" ofType:@"mov"]];

_moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
                                       selector:@selector(moviePlayBackDidFinish:)
                                           name:MPMoviePlayerPlaybackDidFinishNotification
                                         object:_moviePlayer];

_moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
_moviePlayer.view.frame = CGRectMake(184, 200, 400, 300);
[self.view addSubview:_moviePlayer.view];
_moviePlayer.shouldAutoplay = YES;
4

1 回答 1

1

用下面给出的替换一行将解决您的问题。

_moviePlayer.view.center = self.view.center;
于 2012-12-28T15:19:43.563 回答