0

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

3 回答 3

0

self.moviePlayer.frame = self.view.bounds;

于 2013-04-02T18:06:08.037 回答
0

让我们试试这段代码

self.moviePlayer.view.center = self.view.center;
于 2013-04-05T07:07:10.547 回答
0

[videoCubeScene addSubview:moviePlayer.view]; 将它添加到我真正想要的视图中,然后它将是该视图的坐标。将其添加到“self.view”时,它会按原样将其添加到屏幕的左上角,因为坐标是主视图的坐标(整个屏幕)

于 2013-04-09T23:09:12.643 回答