Question

I am trying to add a movie player on top or inside of a uiview I already have on screen. When I place the movieplayer it is at the top left of the screen. The Uiview I want the movie on is in the Center of the screen on the bottom.

I can play with the numbers and move it down by adding points to the "makeframe" but that doesn't seem correct way of doing this. videoCubeSceneView is the view I want the Movie played on.

     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];
Was it helpful?

Solution 3

[videoCubeScene addSubview:moviePlayer.view]; Add it to the view I actually want it in, then it will be to the coordinates of that said view. When adding it to "self.view" it will add it to the top left of the screen just as it should, because the coordinates are of the main view(The entire screen)

OTHER TIPS

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

let try this code

self.moviePlayer.view.center = self.view.center;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top