Reputation: 658
I don't want to play a video in fullscreen, is it possible to play a video inside a view?
Here is my code. It does create a frame and plays the video inside it. The problem is that I don't know how to center on screen the frame (it appears on the right side of the screen)
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;
Upvotes: 0
Views: 985
Reputation: 676
replace a line with given below will fix your issue.
_moviePlayer.view.center = self.view.center;
Upvotes: 1