我想爲iPad創建一個簡單的應用程序,並在單擊按鈕時播放FLV。我使用http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html#VIDEO-USE_THE_MEDIA_PLAYER_FRAMEWORK_FOR_VIDEO_PLAYBACK的代碼作爲參考。這是我能夠成功編譯和運行應用程序爲我的單擊事件我可以在iPad模擬器上播放FLV嗎?
-(IBAction) btnPlayVideoClick:(id) sender {
NSString* videoPath = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"flv"];
MPMoviePlayerController* myMovie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:videoPath]];
myMovie.scalingMode = MPMovieScalingModeAspectFill;
// Register for the playback finished notification.
[[NSNotificationCenter defaultCenter] addObserver:self
selector: @selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:myMovie];
[myMovie play];
}
-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
MPMoviePlayerController* theMovie=[aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
// Release the movie instance created in playMovieAtURL
[theMovie release];
}
的代碼,但是當我點擊按鈕的應用只是沒有錯誤信息或所有的活動中退出。有什麼我做錯了,還是有一些原因,我不能用模擬器玩FLV。我無法在真實設備上測試,因爲我正在等待批准才能獲得我的開發許可證。
感謝,
邁克
我在http://support.apple.com/kb上打開了一個示例quicktime視頻的flv文件/ HT1425的結果相同。我選擇了爲iPod編碼的樣本視頻和爲iTunes編碼的視頻。有什麼我做錯了嗎? – mclark1129 2010-07-27 16:29:41