我試圖創建一個應用程序,該應用程序在視頻停止播放後顯示信息頁面。我看過這裏發佈的類似問題,並試圖實現它,但它仍然無法正常工作。我把一個NSLog放在movieFinishedCallback方法中,但是從來沒有出現過,所以我猜它甚至沒有被調用。有人能幫我弄明白嗎?MovieFinishedCallback通知未觸發
這裏是我的實現代碼...
-(IBAction)playvideo {
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"sample" ofType:@"mov"]];
MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:playercontroller];
[self presentMoviePlayerViewControllerAnimated:playercontroller];
playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
[playercontroller.moviePlayer play];
playercontroller = nil;
}
- (void) movieFinishedCallback:(NSNotification*) notification {
NSLog (@"The video ended");
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
player = nil;
View2 *second =[[View2 alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
}
謝謝@danh!是的,View2是UIViewController的一個子類。我試圖在movieFinishedCallback中添加一個NSLog,它沒有顯示出來,所以它可能沒有被調用。視頻播放良好,但我也得到多個...「錯誤加載/系統/庫/擴展/音頻IPCDriver.kext /內容/ ...」,並在最後說,找不到函數指針NewDigiCoreAudioPlugIn工廠... (捆綁,未加載)。請幫忙? – skinnypinny 2012-08-01 14:08:06
我想你可以在播放時忽略這些錯誤信息。廣泛報告模擬器問題。需要考慮在通知上發出呼叫。你能看看你是否可以得到loadstatechanged通知? – danh 2012-08-01 14:13:38
那也沒有記錄任何東西。 :( – skinnypinny 2012-08-01 14:32:48