我有以下代碼:iOS 5的問題與MPMovieDurationAvailableNotification
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:[arr objectAtIndex:0]]];
moviePlayer.shouldAutoplay = NO;
moviePlayer.useApplicationAudioSession = NO;
//create a NSNotificationCenter which call moviePlaybackComplete function when movie duration available
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieDurationAvailable:) name:MPMovieDurationAvailableNotification object:moviePlayer];
(void) movieDurationAvailable:(NSNotification *)notification
{
NSLog(@"duration of movie : %f", [moviePlayerController duration]);
}
稱爲movieDurationAvailable的方法不會被調用。
你能告訴我我做錯了什麼嗎?
感謝
你沒有開始下載/回放 - 嘗試'[moviePlayer prepareToPlay]' – Till
仍然無法正常工作。 – woody35
普通[moviePlayer play]如何?我必須承認,我從來沒有依賴那個通知,只是簡單地使用了MPMoviePlayerController返回的值。在我的實現中,這是在定時基礎上完成的(例如每0.5秒)。所以,當玩家決定修改估計的遊戲時間時,我的應用程序將從該更正中受益。 – Till