Make sure _imgForVidFrame.frame returns the correct frame every time! You can put a breakpoint on this line to make sure that it returns the correct size or not!
and your last line should be [self.view addSubview:controller.view]; not controller.view.frame =_imgForVidFrame.frame; so replace it!
Update:
then you can do something like below using AVPlayerViewController ,
AVPlayer *player = [AVPlayer playerWithURL:_videoFilePath]; AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player]; playerLayer.frame = self.view.bounds; [self.view.layer addSublayer:playerLayer]; [player play];
or you can imagine something like AVPlayerViewController
AVPlayer *player = [AVPlayer playerWithURL:_videoFilePath]; AVPlayerViewController *playerViewController = [AVPlayerViewController new]; playerViewController.player = player; [self presentViewController:playerViewController animated:YES completion:nil];
source share