【问题标题】:Best way to implement MPMoviePlayer timeout实现 MPMoviePlayer 超时的最佳方法
【发布时间】:2011-05-02 09:34:52
【问题描述】:

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

【问题讨论】:

    标签: iphone objective-c ios4 mpmovieplayercontroller mpmovieplayer


    【解决方案1】:

    注册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 秒。一旦该婴儿用完时间而没有进一步的状态更改,请执行某些操作以终止/跳过视频播放。

    【讨论】:

      【解决方案2】:

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

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

      然后检查电影状态。

      【讨论】:

        猜你喜欢
        • 2021-12-23
        • 2011-11-16
        • 1970-01-01
        • 2012-05-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-10
        • 1970-01-01
        相关资源
        最近更新 更多