I am using MPMovieplayercontroller
to play video it plays the video which comes from web services. Source video file was taken in potrait mode but it has been rotated 90º in anti-clockwise direction. So when i am playing it in MPMovieplayercontroller it is playing like following format attached is the sample image
Is there any way to rotate the video file which comes from web service?
I have tried to apply transform for MPMovieplayercontroller.view
but movie player controls also rotating. my requirement is i would need to rotate the video part only. Is there any way to achieve this. Please help me out to fix this it would be great help.
Thanks in advance
try with this: (I have made 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 to work in that way with the subViews, but it works.. (at least for iOS5 and iOS6)
then, you could try to rotate the viewPlayersVideoContent :)
You need to rotate MPMoviePlayer
view as per the following code.
This will work best. I have 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];
You may achieve this by following code,
yourMoviePlayerController.view.transform = CGAffineTransformMakeRotation(M_PI/2);
and if you want to keep you controls at some place fixed, by default its not possible. So you need to hide the default controls by following code,
yourMoviePlayerController.controlStyle = MPMovieControlModeHidden;
and then add a subView for the controls programatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With