cacheVideo method

dynamic cacheVideo(
  1. int index
)

Implementation

cacheVideo(int index) async {
  if (!isCaching) return;
  String url = videoList[index];
  if (caching.contains(url)) return;
  caching.add(url);
  final cacheManager = DefaultCacheManager();
  FileInfo? fileInfo = await cacheManager.getFileFromCache(url);
  if (fileInfo != null) {
    log('Video already cached: $index');
    return;
  }

  // log('Downloading video: $index');
  try {
    await cacheManager.downloadFile(url);
    // log('Downloaded video: $index');
  } catch (e) {
    // log('Error downloading video: $e');
    caching.remove(url);
  }
}