我有以下代码: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