我正在尝试在屏幕上已有的 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];