1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- part of 'data_host.dart';
- class _VidDataHostBroswer implements VidDataHostInterface {
- _VidDataHostBroswer(this.url);
- @override
- final String url;
- VidUsImageData? _data;
- @override
- int get frameCount => _data!.imageCount;
- @override
- VidUsProbe get probe => _data!.probe;
- @override
- Future<VidUsImageData?> getData() async => _data;
- @override
- Future<VidUsImage> getFrame<TProcessor extends VidFrameProcessor>(
- int index, {
- List<TProcessor>? processors,
- }) async {
- if (_data == null) {
- throw Exception(
- "[VidDataHost] getFrame: must call load first and data is not null.");
- }
- return _data!.getImage(index);
- }
- @override
- Future<VidDataHostLoadInfo?> load() async {
- final bytes = await VidFileDownloader.download(url);
- if (bytes != null && bytes.isNotEmpty) {
- _data = VidUsImageData(bytes);
- final info = VidDataHostLoadInfo(_data!.probe);
- return info;
- }
- return null;
- }
- @override
- Future<void> release() async {
- _data = null;
- }
- }
|