2010-07-01 76 views
0

我有一個基於標籤欄的應用程序與2個選項卡。一個顯示圖像,另一個顯示視頻。如果我點擊視頻標籤,不同的縮略圖顯示出來。如果我點擊這些圖像中的一個,我想推動那個videoviewController在另一個導航視圖中播放視頻 - 如果我轉動iPhone,它將播放全屏。所以,實際上它就像原始的「照片」 - 應用程序一樣的功能。想播放視頻,但只有聲音,沒有可見的內容

到目前爲止我所得到的是一個帶有不同按鈕的scrollview,其中我添加了一個backgroundimage。通過點擊這些按鈕中的一個,從來就添加的按鈕的功能:

  [myButton addTarget:nil action:@selector(buttonDown:) forControlEvents:UIControlEventTouchUpInside]; 

而且here's我 「的buttonDown」 - 方法:

-(void) buttonDown:(NSString*) sender { 
moviePlayer = [[MoviePlayer alloc] init]; 
[self.view addSubview:moviePlayer.view]; 

NSLog(@"MoviePlayer: %@", moviePlayer); 
[self.navigationController pushViewController:moviePlayer animated:YES]; 

[moviePlayer release];} 

Here's我「MoviePlayer.m 「-file:

- (void)viewDidLoad { 

UIView* imageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)]; 
imageView.backgroundColor = [UIColor greenColor]; 
[self.view addSubview:imageView]; 
[imageView release]; 

NSString *url = [[NSBundle mainBundle] pathForResource:@"testmovie" ofType:@"mp4"]; 
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; 
//player.scalingMode = MPMovieScalingModeAspectFill; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:player]; 

[player play];  
[super viewDidLoad];  

}

- (void) movieFinishedCallback:(NSNotification*) aNotification { 
MPMoviePlayerController *player = [aNotification object]; 
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];  
[player autorelease];  

}

所以導航效果很好 - 通過點擊按鈕,視圖被推送(並且我得到了我的綠色測試視圖),並且該視頻文件的聲音正在播放 - 但沒有視頻可見那個聲音。

我不知道 - 如果我在一個新的基於視圖的項目模板中測試代碼,它的效果很好。所以我認爲這些意見存在一些問題。

有關於此的任何想法? 會很好。謝謝你的時間。

回答

0

給這個一展身手:

[玩家setFullscreen:YES]; [self presentMoviePlayerViewControllerAnimated:player];

我相信應該解決你的難題!如果協助,請投票回答!

相關問題