我一直在試圖弄清楚這一點,並試圖按照任何建議那裏,但我似乎無法'MPMoviePlayerPlaybackDidFinishNotification'在用戶按'完成'在電影播放器上。當電影播放器上按下'DONE'時,MPMoviePlayerPlaybackDidFinishNotification不起作用
- (void)myMovieFinishedCallback:(NSNotification*)aNotification {
MPMoviePlayerController* theMovie=[aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
[theMovie pause];
[theMovie stop];
[theMovie autorelease];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
}
- (void)myMovieViewFinishedCallback:(NSNotification*)aNotification {
MPMoviePlayerViewController* theMovieView=[aNotification object];
[self dismissMoviePlayerViewControllerAnimated];
[[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovieView];
[theMovieView pause];
[theMovieView stop];
[theMovieView autorelease];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
}
- (IBAction)safetyVideo:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"Ball_Crunch" ofType:@"m4v"];
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 3.2) {
MPMoviePlayerViewController*tmpMoviePlayViewController=[[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]] retain];
if (tmpMoviePlayViewController) {
[self presentMoviePlayerViewControllerAnimated:tmpMoviePlayViewController];
tmpMoviePlayViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieViewFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:tmpMoviePlayViewController];
[tmpMoviePlayViewController.moviePlayer play];
}
}else{
MPMoviePlayerController* theMovie = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]] retain];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
[theMovie play];
}
}
當'完成'被按下但電話從未被調用時,電影播放正常並消失。有什麼建議麼?
謝謝。
有人在嗎? *蟋蟀* – Entekis 2011-03-04 05:41:41