我在面對一個ipad視頻合併問題。我的代碼工作正常我的意思是播放視頻,但一旦視頻到達結束。回調方法不被調用。iPad videoPlayerDidFinishPlaying回調方法沒有響應
按下播放視頻按鈕時調用此方法。
-(IBAction) playVideo : (id) sender
{
[self initPlayingVideo:@"toyVid.mp4"];
}
該方法處理視頻播放。
-(void) initPlayingVideo: (NSString *) videoFile
{
NSString *moviePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:videoFile];
theMovie = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
theMovie.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
theMovie.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
[self.view addSubview:theMovie.view];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(videoPlayerDidFinishPlaying
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
videoPlayer = [theMovie moviePlayer];
[videoPlayer play];
}
這是回調方法。
-(void) videoPlayerDidFinishPlaying: (NSNotification*)aNotification
{
theMovie = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie.moviePlayer];
[videoPlayer stop];
[theMovie.moviePlayer release];
[videoPlayer release];
[theMovie.view removeFromSuperview];
}
我在哪裏做錯了?請指導。在您的選擇和):
問候 蘭詹
您可能會考慮將代碼放在代碼段中:只需在代碼前放置四個空格即可。 – 2010-07-15 05:17:49