Ios5 iOS 5问题,MPMovieDurationAvailableNotification
我有以下代码:Ios5 iOS 5问题,MPMovieDurationAvailableNotification,ios5,mpmovieplayercontroller,Ios5,Mpmovieplayercontroller,我有以下代码: MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:[arr objectAtIndex:0]]]; moviePlayer.shouldAutoplay = NO; moviePlayer.useApplicationAudioSession = NO; //create a NSNotificationCe
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的方法
你能告诉我我做错了什么吗
谢谢,如果您正在使用ARC,则不会调用通知,因为moviePlayer可能会在超出范围后立即解除锁定。66复制副本是正确的。改为在.h文件中声明moviePlayer,并将[moviePlayer play]添加到上面的代码中以解决此问题。您没有开始下载/播放--请尝试
[moviePlayer prepareToPlay]
普通的[moviePlayer play]怎么样?我必须承认,我从未依赖于该通知,只是使用了MPMoviePlayerController返回的任何值。在我的实现中,这是在定时的基础上完成的(例如,每0.5秒)。因此,当玩家决定修改估计的播放时间时,我的应用程序将从中受益。如果我需要通过不启动电影来获得电影持续时间,该怎么办?