I am using the MPMoviePlayerController to play the live streaming videos, and the code which I am using is

[_moviePlayerController.view setFrame:self.view.bounds];
[_moviePlayerController prepareToPlay];
_moviePlayerController.fullscreen=YES;
_moviePlayerController.controlStyle = MPMovieControlStyleNone;
[_moviePlayerController setFullscreen:YES animated:YES];
[self.view addSubview:_moviePlayerController.view];

Video is playing in all orientations. But I have added one button on top of the movieplayer which lets you to scale the video.

I know in mediaplayer framework we are having MPMovieScalingModeNone,MPMovieScalingModeAspectFit,MPMovieScalingModeAspectFill and MPMovieScalingModeFill types of scaling mode option. When the button is pressed down, I am setting the scaling mode as MPMovieScalingModeAspectFill , when it is pressed second time MPMovieScalingModeAspectFit. This is also works great in the iPhone. But when I am not able to do any scaling operation when I am using the iPad LANDSCAPE Mode. Neither I am not able to use Fit or fill scaling mode when the iPad is in the Landscape mode.

Why ? What could be the reason ?

有帮助吗?

解决方案

If the video aspect ratio already fits perfectly onto the display (view) aspect ratio, none of the fit/fill operations have any effect. That is by design and not a problem.

You should hide or disable that button once such perfect fit is available. To compare the video aspect ratio towards the view's aspect ratio, use the naturalSize property of the player.

naturalSize

The width and height of the movie frame. (read-only)

@property (nonatomic, readonly) CGSize naturalSize

Discussion

This property reports the clean aperture of the video in square pixels. Thus, the reported dimensions take into account anamorphic content and aperture modes.

It is possible for the natural size of a movie to change during playback. This typically happens when the bit-rate of streaming content changes or when playback toggles between audio-only and a combination of audio and video.

其他提示

U can provide random scaling like this:

[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{

  moviePlayer.view.transform = CGAffineTransformMakeScale(0.7f, 0.7f);

} completion:^(BOOL finished){
    // if you want to do something once the animation finishes, put it here
}];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top