發現了它。
有同樣的問題 - 這裏是我做的。我會建議將代碼逐個添加到您的項目中,以查看它的工作原理。
首先 - 我放東西的是肖像模式。
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
然後我把電影推到狀態欄上。注意 - 這是假設視頻有一個4×3寬高比
theVideo = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath : path]];
float aspectRatio = (3.0f/4.0f);
float theMovieHeight = [self view].bounds.size.width * aspectRatio;
[[theVideo view] setFrame:(CGRectMake(0, [self view].bounds.size.height - theMovieHeight, [self view].bounds.size.width, theMovieHeight))];
然後,在應用程序啓動時的地方(在我的項目,它是在didFinishLaunchingWithOptions
功能) - 反正,你只需要訪問窗口對象。
float aspectRatio = (3.0f/4.0f);
float theMovieHeight = self.window.bounds.size.width * aspectRatio;
float theSpaceAboveTheMovie = self.window.bounds.size.height - theMovieHeight;
float whereTheMovieShouldBeCentered = (self.window.bounds.size.height - theMovieHeight)/2;
CGAffineTransform theTransform = CGAffineTransformMakeTranslation(0,0);
theTransform = CGAffineTransformScale(theTransform, 1.0f/aspectRatio, 1.0f/aspectRatio);
theTransform = CGAffineTransformTranslate(theTransform, -whereTheMovieShouldBeCentered, 0);
theTransform = CGAffineTransformRotate(theTransform, M_PI/2);
theTransform = CGAffineTransformTranslate(theTransform, 0, -theSpaceAboveTheMovie);
[self.window setTransform:theTransform];
請記住,仿射變換是以相反的順序完成的。所以,如果你想看看每個變換做(我建議你應該),註釋掉前三
在這裏,你會看到在頁面上居中
// theTransform = CGAffineTransformScale(theTransform, 1.0f/aspectRatio, 1.0f/aspectRatio);
// theTransform = CGAffineTransformTranslate(theTransform, -whereTheMovieShouldBeCentered, 0);
// theTransform = CGAffineTransformRotate(theTransform, M_PI/2);
theTransform = CGAffineTransformTranslate(theTransform, 0, -theSpaceAboveTheMovie);
然後電影和狀態欄第一2
這裏你應該看的電影和狀態欄旋轉,不再集中
// theTransform = CGAffineTransformScale(theTransform, 1.0f/aspectRatio, 1.0f/aspectRatio);
// theTransform = CGAffineTransformTranslate(theTransform, -whereTheMovieShouldBeCentered, 0);
theTransform = CGAffineTransformRotate(theTransform, M_PI/2);
theTransform = CGAffineTransformTranslate(theTransform, 0, -theSpaceAboveTheMovie);
在這裏,你應該看到它旋轉和居中
// theTransform = CGAffineTransformScale(theTransform, 1.0f/aspectRatio, 1.0f/aspectRatio);
theTransform = CGAffineTransformTranslate(theTransform, -whereTheMovieShouldBeCentered, 0);
theTransform = CGAffineTransformRotate(theTransform, M_PI/2);
theTransform = CGAffineTransformTranslate(theTransform, 0, -theSpaceAboveTheMovie);
並與他們一起,它旋轉和全屏
您可以下載我的示例代碼here。
我遇到了同樣的問題。仍然沒有解決方法? – samvermette 2010-06-09 18:03:35
我也是。任何人都有這個工作? – V1ru8 2010-08-18 14:40:01
你有答案嗎? – Jingwei 2013-06-28 00:59:44