|
@@ -26,6 +26,10 @@ abstract class VidDataChannel {
|
|
|
return VidDataChannelImpl(url);
|
|
|
}
|
|
|
|
|
|
+ static void receiveChunk(String id, Uint8List chunk) {
|
|
|
+ VidDataChannelImpl.receiveChunk(id, chunk);
|
|
|
+ }
|
|
|
+
|
|
|
/// 下载进度变更事件
|
|
|
final downloadProgressChanged = FEventHandler<VidDownloadProgressInfo>();
|
|
|
|
|
@@ -41,29 +45,9 @@ abstract class VidDataChannel {
|
|
|
if (_initialized) return true;
|
|
|
|
|
|
try {
|
|
|
- final completer = Completer<bool>();
|
|
|
- final timer = Timer(
|
|
|
- Duration(milliseconds: timeout),
|
|
|
- () {
|
|
|
- if (!completer.isCompleted) {
|
|
|
- completer.complete(_initialized);
|
|
|
- }
|
|
|
- if (!_initialized) {
|
|
|
- source?.close();
|
|
|
- }
|
|
|
- },
|
|
|
- );
|
|
|
- _innerLoad(timeout).then((value) {
|
|
|
- _initialized = true;
|
|
|
- if (timer.isActive) {
|
|
|
- timer.cancel();
|
|
|
- }
|
|
|
- completer.complete(true);
|
|
|
- });
|
|
|
- return completer.future;
|
|
|
- } catch (e) {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ _initialized = await _innerLoad(timeout);
|
|
|
+ } catch (e) {}
|
|
|
+ return _initialized;
|
|
|
}
|
|
|
|
|
|
/// 分发下载进度回调
|