download method

  1. @override
Future<Uint8List?> download(
  1. DownloadTask task
)
override

Downloads data from the network for the given task.

Returns a Uint8List containing the downloaded data, or null if the download fails.

Implementation

@override
Future<Uint8List?> download(DownloadTask task) async {
  logD('From network: ${task.url}');
  Uint8List? dataNetwork;
  task.cacheDir = await FileExt.createCachePath(task.hlsKey);
  await VideoProxy.downloadManager.executeTask(task);
  await for (DownloadTask taskStream in VideoProxy.downloadManager.stream) {
    if (taskStream.status == DownloadStatus.COMPLETED &&
        taskStream.url == task.url) {
      dataNetwork = Uint8List.fromList(taskStream.data);
      break;
    }
  }
  return dataNetwork;
}