flutter_vap icon indicating copy to clipboard operation
flutter_vap copied to clipboard

playAsset 不能正常播放,error:draw text resource fail cuz text is nil

Open once-liu opened this issue 1 year ago • 0 comments

环境:

  • Flutter 3.13.0
  • Dart 3.1.0
  • iPhone 14 Pro,iOS 16.3.1

操作: 拷贝了 vap 项目中的 mp4 资源到 Flutter 项目中的 assets 目录下。调用 playAsset 方法。

log:

<2> UIView+VAP.m(269):-[UIView(VAP) p_playHWDMP4:fps:blendMode:repeatCount:delegate:] [kQGVAPModuleCommon] - try to display mp4:/private/var/containers/Bundle/Application/854C300F-72E0-4748-A923-07C348A4AB3B/Runner.app/Frameworks/App.framework/flutter_assets/assets/video/vap.mp4 blendMode:0 fps:0 repeatCount:0
<2> QGMP4FrameHWDecoder.m(337):-[QGMP4FrameHWDecoder initPPSnSPS] [kQGVAPModuleCommon] - initPPSnSPS
<5> QGVAPTextureLoader.m(65):+[QGVAPTextureLoader drawingImageForText:color:size:bold:] [kQGVAPModuleCommon] - draw text resource fail cuz text is nil !!
<5> QGVAPTextureLoader.m(65):+[QGVAPTextureLoader drawingImageForText:color:size:bold:] [kQGVAPModuleCommon] - draw text resource fail cuz text is nil !!

疑问: 我看到 QGVAPTextureLoader 文件中的 contentTagValue 的设置可以为 nil:

- (NSString *)vap_contentForTag:(NSString *)tag resource:(QGVAPSourceInfo *)info {
    
    if ([self.hwd_Delegate respondsToSelector:@selector(contentForVapTag:resource:)]) {
        return [self.hwd_Delegate contentForVapTag:tag resource:info];
    }
    return nil;
}

为什么QGVAPTextureLoader+ (UIImage *)drawingImageForText:(NSString *)textStr color:(UIColor *)color size:(CGSize)size bold:(BOOL)bold 方法不允许 textStr 为 nil 呢?

+ (UIImage *)drawingImageForText:(NSString *)textStr color:(UIColor *)color size:(CGSize)size bold:(BOOL)bold {
    
    if (textStr.length == 0) {
        VAP_Error(kQGVAPModuleCommon, @"draw text resource fail cuz text is nil !!");
        return nil;
    }
    // ....
}

如何解决这个问题呢?

once-liu avatar Dec 28 '23 04:12 once-liu