我有从流加载电影的MPMoviePlayer。我用计时器实现了15秒的超时。但是,有没有其他更好的方法来实现没有计时器的超时呢?
发布于 2011-05-03 20:29:20
注册MPMoviePlayerLoadStateDidChangeNotification。在它的处理程序中,检查当前的加载状态并屏蔽MPMovieLoadStateStalled。
- (void)MPMoviePlayerLoadStateDidChange:(NSNotification *)notification
{
//is the player stalled, hence possibly starving?
if ((movieController_.loadState & MPMovieLoadStateStalled) == MPMovieLoadStateStalled)
{ //yes->do something
NSLog(@"hey there, I am starving to death here");
}
}你可能想在上面的if子句中注册一个计时器,例如10秒。一旦婴儿在没有进一步状态更改的情况下耗尽时间,执行某些操作来终止/跳过视频回放。
发布于 2011-10-05 18:12:22
我不确定,但我认为可以使用performSelector作为计时器?
[self performSelector:@selector(checkTimeout:) withObject:theMovie afterDelay:15];然后检查电影状态。
https://stackoverflow.com/questions/5855562
复制相似问题