How to rotate 90ยบ video in MPMovieplayercontroller

I am using MPMovieplayercontroller to play a video that plays video that comes from web services. The original video was taken in potrait mode, but it was rotated 90ยบ counterclockwise. Therefore, when I play it in MPMovieplayercontroller , it plays, as in the following format: sample image enter image description here

Is there a way to rotate a video file that comes from a web service?

I tried applying a transform to MPMovieplayercontroller.view , but the player controls also rotate. my requirement is that I will only need to rotate part of the video. Is there any way to achieve this. Please help me fix this, it will be a big help.

Thank you in advance

+6
source share
3 answers

try with this: (I created a subclass for MPMoviePlayerViewController)

 - (void)configureSubViews { if (self.moviePlayer.view.subviews.count > 0) { UIView *view = self.moviePlayer.view.subviews[0]; if (view.subviews.count > 0) { UIView *sView = view.subviews[0]; self.viewPlayerVideoContent = [sView viewWithTag:1002]; self.viewPlayerControls = [sView viewWithTag:1003]; } } } 

I don't really like working with subViews, but it works .. (at least for iOS5 and iOS6)

then you can try to rotate viewPlayersVideoContent :)

+2
source

You need to rotate MPMoviePlayer according to the following code. This will work best. I tested it.

  NSURL *fileUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Video" ofType:@"mp4"]]; MPMoviePlayerViewController *moviePlayerController = [[MPMoviePlayerViewController alloc]initWithContentURL:fileUrl]; [moviePlayerController.moviePlayer prepareToPlay]; [moviePlayerController.moviePlayer setRepeatMode:MPMovieRepeatModeOne]; [moviePlayerController.moviePlayer setControlStyle:MPMovieControlStyleEmbedded]; moviePlayerController.view.transform = CGAffineTransformMakeRotation(M_PI/2); [self.view addSubview:moviePlayerController.view]; 
+2
source

You can achieve this by following the code,

 yourMoviePlayerController.view.transform = CGAffineTransformMakeRotation(M_PI/2); 

and if you want you to control some place in a fixed place, by default it is not possible. Therefore, you need to hide the default controls by running the following code:

 yourMoviePlayerController.controlStyle = MPMovieControlModeHidden; 

and then programmatically add a subspecies for the controls.

+1
source

Source: https://habr.com/ru/post/953543/


All Articles