2011-05-25 54 views
1

我有一個視頻保存在我的xcode項目中,我想扮演一個響應點擊按鈕。 IOS是否內置了媒體API來處理這個問題?任何人都可以提供在iPhone上處理視頻的類名嗎?你如何在你的應用中播放視頻?

+5

http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MediaPlayer_Framework/_index.html – Bart 2011-05-25 21:03:42

+0

我很感激Bart。 – Jackelope11 2011-05-25 21:05:38

回答

1

下面是一些代碼,讓你開始:

MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"yourfilename" ofType:@"m4v"]]]; 
     [[moviePlayerController view] setFrame:CGRectMake(0, 0, parentView.frame.size.width, parentView.frame.size.height)]; 
     [moviePlayerController setShouldAutoplay:NO]; 
     [moviePlayerController setControlStyle:MPMovieControlStyleEmbedded]; 
     [[moviePlayerController backgroundView] setBackgroundColor:[UIColor clearColor]]; 
     [moviePlayerController prepareToPlay]; 

通過您設置的MPMoviePlayerController與大如父視圖的一幀一幀的文檔。

+0

謝謝,我會做一些非常相似的事情。 – Jackelope11 2011-05-26 13:40:34

0

是的iOS確實包含媒體API來處理。

1

MPMoviePlayerViewController。在提問之前請稍微搜索一下。

+0

對不起,我曾經在某個地方看到過,但它並沒有馬上工作。 – Jackelope11 2011-05-25 21:04:00