react-native-video(Cannot remove an observer <RCTVideo 0x123e3f990> for the key path "readyForDis...

描述:

切换播放源的时候报错:Exception thrown while executing UI block: Cannot remove an observer <RCTVideo 0x123e3f990> for the key path "readyForDisplay" from <AVPlayerLayer 0x1c4625060> because it is not registered as an observer
解决:
在该框架的作者下面发现的
链接是这个:https://github.com/react-native-community/react-native-video/issues/907,有兴趣的可以去看看。
解决办法如下:
在xcode中找到RCTVideo.m文件,然后找到方法removePlayerLayer,将方法的实现修改为:

[_playerLayer removeFromSuperlayer];
    @try {
        [_playerLayer removeObserver:self forKeyPath:readyForDisplayKeyPath];
    } @catch (NSException *e) { }
      _playerLayer = nil;

用xcode重新编译运行即可解决。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容