import 'dart:typed_data'; import 'package:vid/us/vid_us_data_http_reader.dart'; import '../reader.dart'; class AsyncHttpVidDataReader extends AsyncVidDataReaderBase { late final VidUsDataHttpReader _inner; DownloadCallback? downloadCallback; AsyncHttpVidDataReader( String url, { this.downloadCallback, int minChunkSize = 65536, int connectTimeout = 30000, int receiveTimeout = 30000, }) : super(url, downloadCallback: downloadCallback) { _inner = VidUsDataHttpReader( url, downloadCallback: _onDownloadCallback, minChunkSize: minChunkSize, connectTimeout: connectTimeout, receiveTimeout: receiveTimeout, ); setBytesProxy(_inner.toBytes); } @override Uint8List toBytes() { return _inner.toBytes(); } @override void close() { _inner.close(); } @override void startDownload() {} @override void skipToFrame(int index) {} void _onDownloadCallback(double progress, DownloadErrorException? error) { downloadCallback?.call(progress, error); final bufferedSize = (progress * totalSize).toInt(); setBufferSize(bufferedSize); } @override Future fetchFrames(int startIndex, int size, {bool isNeedReload = false}) async {} }