channel.dart 621 B

12345678910111213141516171819202122232425262728
  1. import 'package:fis_vid/async_vid/vid_data.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:vid/us/vid_us_image.dart';
  4. abstract class VidDataChannel {
  5. late final AsyncVidImageDataBase _source;
  6. /// 开始加载数据
  7. Future<bool> load() async {
  8. try {
  9. _source = await buildSource();
  10. await _source.initialize();
  11. return true;
  12. } catch (e) {
  13. return false;
  14. }
  15. }
  16. /// 获取指定帧
  17. ///
  18. /// [index] 帧索引
  19. Future<VidUsImage> getImage(int index) async {
  20. return _source.getImage(index);
  21. }
  22. @protected
  23. Future<AsyncVidImageDataBase> buildSource();
  24. }