如何阻止MPMoviePlayerController显示“此电影无法播放。”?

我使用
MPMoviePlayerController
在iPhone上播放一些视频和音频流。 有时一些流量不可用,所以在iPhone OS 3.1上我得到4“这部电影无法播放”警报,即使我收到所有通知。 谁能告诉我如何防止这种情况发生?     
已邀请:
我很遗憾地告诉你,这是(据我所知)不可能做到的。 我也处理过同样的问题,即使我花了很多时间调查这个问题,我也找不到解决方案。     
为了防止
MPMoviePlayerController
显示
UIAlertView
警报,您可以使用以下方法: 将以下方法添加到您的应用程序委托中,并确保在启动时只调用一次
patchMPVVC
#import "/usr/include/objc/objc-runtime.h"

- (void)_handleError:(NSNotification *)notification {
    // do nothing, or add any custom error handling code here
}

- (void)patchMPVVC {
    // add the _handleError: method to the MPVideoViewController class
    Class class = NSClassFromString(@"MPVideoViewController");
    Method myMethod = class_getInstanceMethod([self class], @selector(_handleError:));
    class_addMethod(class, @selector(_handleError:), method_getImplementation(myMethod), "v@:@");

    // swap method implementations:
    SEL selector = sel_registerName("_videoView_playbackErrorNotification");
    Method originalMethod = class_getInstanceMethod(class, selector);       
    myMethod = class_getInstanceMethod(class, @selector(_handleError:));
    method_exchangeImplementations(originalMethod, myMethod);
}
请记住,这个代码可能会被苹果拒绝,因为它引用了私有的
MPVideoViewController
类和
_videoView_playbackErrorNotification
方法。     

要回复问题请先登录注册