xcode MPMoviePlayerController 不会设置为我声明的大小框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12035393/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MPMoviePlayerController will not set to the size frame I am declaring
提问by Elliott D'Alvarez
I am currently trying to set the frame for an MPMoviePlayerController which is stored in a custom class (VideoEngine). The movie is set using a URL which is provided by a video which the users capture during the application. (I hope this bit makes sense). I am then setting up the MPMoviePlayerControllers view as follows:
我目前正在尝试为存储在自定义类 (VideoEngine) 中的 MPMoviePlayerController 设置框架。电影使用 URL 设置,该 URL 由用户在应用程序期间捕获的视频提供。(我希望这有点道理)。然后我设置 MPMoviePlayerControllers 视图如下:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//[self.image setImage:[info objectForKey:UIImagePickerControllerMediaURL]];
videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
[parentView dismissModalViewControllerAnimated:NO];
VideoEngine *ve = [[VideoEngine alloc] initWithCallbackName:@"movieFinishedPlaying"];
[ve loadMovieURL:videoURL];
[ve.player.view setFrame:CGRectMake((0 + self.frame.size.width * 0.2), self.frame.size.height * 0.3, self.frame.size.width * 0.6, self.frame.size.width * 0.4)];
CGRect frame = ve.player.view.frame;
self.video = ve;
[self addSubview:self.video.player.view];
[ve release];
}
Firstly, I would like to point out that I know the height values is set using the width but that's to keep it wider then it is high (not fussed about the way this is done at the moment). As you can see I have a pointer to the view's frame so I can check the values (it wouldn't let me access directly using po). Below is a screenshot of the values:
首先,我想指出的是,我知道高度值是使用宽度设置的,但这是为了使其更宽,然后才高(目前并不大惊小怪)。如您所见,我有一个指向视图框架的指针,因此我可以检查值(它不会让我直接使用 po 访问)。下面是值的屏幕截图:
As you can see (just about), the frame is 192 wide x 128 high which is fine. However when I am looking at this within the phone it looks as follows:
如您所见(大约),框架为 192 宽 x 128 高,这很好。但是,当我在手机中查看此内容时,它看起来如下:
The phone has all rotation disabled so it should never be trying to resize in a weird way due to rotation. I am getting really confused by this, so if anyone has any ideas I will be very grateful.
手机已禁用所有旋转,因此它不应该因旋转而尝试以奇怪的方式调整大小。我对此感到非常困惑,所以如果有人有任何想法,我将不胜感激。
回答by Elliott D'Alvarez
Okay, turns out that the MPMovieScaling mode was set to aspect fit, I don't know how I overlooked this but just incase people are running in to the same issue you just need to set this somewhere:
好吧,原来 MPMovieScaling 模式设置为方面适合,我不知道我是如何忽略这一点的,但以防万一人们遇到同样的问题,您只需要在某处设置它:
[mpMoviePlayerControllerInstance setScalingMode:MPMovieScalingModeFill];
回答by NANNAV
change MPMoviePlayerController as your movie player name
将 MPMoviePlayerController 更改为您的电影播放器名称
[yourplayername setScalingMode:MPMovieScalingModeFill];
//it fit full frame of the view
//它适合视图的全帧
回答by atulkhatri
I think this would be a much better option as it avoids video to be squeezed:
我认为这将是一个更好的选择,因为它避免了视频被挤压:
[self.moviePlayer setScalingMode:MPMovieScalingModeAspectFill];