我是xcode,界面生成器和iphone模擬器的新手。我試圖通過單擊按鈕(這非常簡單)在xcode中播放電影/視頻。我正在使用xcode 3.2.4和iphone模擬器4.1。視頻沒有在iPhone模擬器中顯示(但我可以聽到來自視頻的音頻)
當我啓動iPhone模擬器並點擊按鈕啓動視頻時,音頻播放,但視頻被隱藏。就好像視頻在標籤欄後面(這是標籤欄應用程序的一部分)。我不知道如何讓視頻在前面播放。
下面的代碼:
-(IBAction)launchVideo2:(id)sender{
NSString *movieFile;
MPMoviePlayerController *moviePlayer;
movieFile = [[NSBundle mainBundle]
pathForResource:@"IGDIs_Video_Picture_Naming_iPhone" ofType:@"mp4"];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL: [NSURL fileURLWithPath: movieFile]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playMediaFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[moviePlayer play];
}
-(void)playMediaFinished:(NSNotification*)theNotification
{
MPMoviePlayerController *moviePlayer=[theNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer release];
}
任何建議將是巨大的!
我不是最大的閱讀/理解文檔還沒有...你有一個使用MPMoviePlayerViewController的代碼的例子嗎? – Justin 2010-11-04 02:35:37
試一下stackoverflow問題http://stackoverflow.com/questions/4077096/how-can-i-play-a-movie-locally-with-the-mpmovieplayerviewcontroller – 2010-11-04 02:43:54
我從你上面提供的例子中精確地複製了代碼並添加了建議的代碼: – Justin 2010-11-07 00:35:07