我正在尝试在屏幕上已有的uiview的顶部或内部添加电影播放器。当我放置电影播放器时,它位于屏幕的左上角。我希望电影的Uiview位于屏幕中央的底部。
我可以使用数字并通过向“makeframe”添加点来向下移动,但这似乎不是正确的方法。 videoCubeSceneView是我希望电影播放的视图。
NSString*thePath=[[NSBundle mainBundle] pathForResource:@"cubeVideo" ofType:@"mp4"];
NSURL*theurl=[NSURL fileURLWithPath:thePath];
moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:theurl];
[moviePlayer.view setFrame:CGRectMake(videoCubeSceneView.frame.origin.x, videoCubeSceneView.frame.origin.y, videoCubeSceneView.frame.size.width, videoCubeSceneView.frame.size.height)];
[moviePlayer prepareToPlay];
[moviePlayer play];
moviePlayer.movieSourceType = MPMovieSourceTypeFile;
moviePlayer.scalingMode = MPMovieScalingModeFill;
moviePlayer.controlStyle = MPMovieControlStyleDefault;
NSLog(@"url : %@", moviePlayer.contentURL);
[moviePlayer setShouldAutoplay:NO]; // And other options you can look through the documentation.
[self.view addSubview:moviePlayer.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playBackStateDidChange) name:MPMoviePlayerPlaybackStateDidChangeNotification object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playBackFinished) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
答案 0 :(得分:0)
self.moviePlayer.frame = self.view.bounds;
答案 1 :(得分:0)
试试这段代码
self.moviePlayer.view.center = self.view.center;
答案 2 :(得分:0)
[videoCubeScene addSubview:moviePlayer.view]; 将它添加到我实际想要的视图中,然后它将是所述视图的坐标。将其添加到“self.view”时,它会将其添加到屏幕的左上方,因为坐标属于主视图(整个屏幕)