part of 'data_host.dart'; class _VidDataHostShell implements VidDataHostInterface { _VidDataHostShell(this.url); static PlatformService get _platform => VidDataHostEnv.platformGetter!.call(); VidUsImageData? _data; @override final String url; @override int get frameCount => _data == null ? -1 : _data!.imageCount; @override VidUsProbe get probe => _data!.probe; @override Future getData() async => _data; @override Future load() async { final rst = await getVidFile(url); if (rst == null || rst.isEmpty) return null; final buffer = const Base64Decoder().convert(rst); _data = VidUsImageData(buffer); final info = VidDataHostLoadInfo(_data!.probe); return info; } ///获取vid文件 Future getVidFile(String url, {int times = 0}) async { try { return await _platform.getVidFile(url); } catch (e) { logger.e('_VidDataHostShell load $times ex:', e); if (times < 2) { return await getVidFile(url, times: times++); } return null; } } @override Future getFrame(int index) async => _data?.getImage(index); @override Future release() async { _data = null; } }