getDownloadInfo method
Gets detailed download progress information for a video. Returns a DownloadProgress object with progress and bytes information.
Implementation
@override
Future<DownloadProgress> getDownloadInfo(String url) async {
try {
// First get the progress
final progress = await getDownloadProgress(url);
// If we have cached info, update it with the new progress
if (_lastReportedInfo.containsKey(url)) {
final lastInfo = _lastReportedInfo[url]!;
final updatedInfo = DownloadProgress(
url: url,
progress: progress,
bytesDownloaded: lastInfo.bytesDownloaded,
);
return updatedInfo;
}
// Otherwise create a new info object with progress and 0 bytes
return DownloadProgress(url: url, progress: progress, bytesDownloaded: 0);
} catch (e) {
debugPrint('Error getting download info: $e');
return DownloadProgress(url: url, progress: 0.0, bytesDownloaded: 0);
}
}