2010-04-28 65 views
2

可能重複:
Using MPMoviePlayerViewController in SDK 3.2 for iPad可可觸摸SDK 3.2 - 如何播放視頻

如何播放視頻SDK 3.2(iPad版)?

在這裏閱讀很多問題,但他們主要討論iPhone。
例如,這裏的MoviePlayer示例http://developer.apple.com/iphone/library/samplecode/MoviePlayer_iPhone/Introduction/Intro.html

這對3.1.3起作用,但是當我在3.2上運行它時,它不起作用。

所以基本上我可以在使用此代碼,但相同的代碼將無法在3.2

的NSString運行播放視頻3.1.3 * moviePath = [[[一個NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@ 「Movie.mp4」];

MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]]; 

moviePlayer.movieControlMode = MPMovieControlModeDefault; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; 

[moviePlayer play]; 

感謝,
三通

回答

0

我得到它的工作。這裏是如何:

NSURL* videoURL = [NSURL URLWithString:url]; 
MPMoviePlayerController moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL]; 
[moviePlayer prepareToPlay]; 
[moviePlayer play]; 
[self.view addSubview:moviePlayer.view]; 

感謝,
三通