1

我有 MPMoviePlayer 从流中加载电影。我用定时器实现了 15 秒的超时。但是是否有其他更好的方法可以在没有计时器的情况下实现超时?

4

2 回答 2

0

注册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-05-03T12:29:20.113 回答
0

我不确定,但我认为可以performSelector用作计时器?

[self performSelector:@selector(checkTimeout:) withObject:theMovie afterDelay:15];

然后检查电影状态。

于 2011-10-05T10:12:21.933 回答