【问题标题】:How to tell a message sent to the MPMediaPlayer has timed out?如何判断发送到 MPMediaPlayer 的消息已超时?
【发布时间】:2009-08-02 22:08:18
【问题描述】:

我一直在使用 3.0 SDK 的 MPMediaPlayer 框架。有时媒体播放器响应缓慢,或根本不响应。我在控制台中收到警告消息,但用户永远不会看到这些消息(因此将超时归咎于我的应用程序)。

有没有办法从这些超时中恢复?我也可以设置不重试吗?

【问题讨论】:

    标签: iphone frameworks media-player


    【解决方案1】:

    您的应用是否注册以接收来自 MPMediaPlayer 的通知?我没有看到这些超时,所以我不知道他们返回的 MPMoviePlayerContentPreloadDidFinishNotification 是否带有你的错误填充的 userInfo。

    来自 MPMoviePlayerController.h:

    MP_EXTERN NSString *const MPMoviePlayerContentPreloadDidFinishNotification; // userInfo contains NSError for @"error" key if preloading fails
    

    来自 MoviePlayer 示例代码:

    // Register to receive a notification that the movie is now in memory and ready to play
    [[NSNotificationCenter defaultCenter] addObserver:self 
                     selector:@selector(moviePreloadDidFinish:) 
                     name:MPMoviePlayerContentPreloadDidFinishNotification 
                     object:nil];
    
    // Register to receive a notification when the movie has finished playing. 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                    selector:@selector(moviePlayBackDidFinish:) 
                    name:MPMoviePlayerPlaybackDidFinishNotification 
                    object:nil];
    
    // Register to receive a notification when the movie scaling mode has changed. 
    [[NSNotificationCenter defaultCenter] addObserver:self 
                    selector:@selector(movieScalingModeDidChange:) 
                    name:MPMoviePlayerScalingModeDidChangeNotification 
                    object:nil];
    

    【讨论】:

    • 我的应用确实注册了自己的通知,但是,我使用的是 MPMusicPlayer,而不是电影播放器​​。不过,这似乎是一个值得关注的方向。谢谢!
    猜你喜欢
    • 2011-12-31
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    • 1970-01-01
    • 2020-10-30
    • 2012-10-26
    • 2019-05-31
    • 2011-10-22
    相关资源
    最近更新 更多