mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-09 00:37:31 +00:00
fix: download not working other than jiosaavn
This commit is contained in:
parent
3de153e478
commit
527ca254ac
@ -28,21 +28,21 @@ class DownloadItem extends HookConsumerWidget {
|
||||
final notifier = downloadManager.getStatusNotifier(track as SourcedTrack);
|
||||
|
||||
taskStatus.value = notifier?.value;
|
||||
listener() {
|
||||
|
||||
void listener() {
|
||||
taskStatus.value = notifier?.value;
|
||||
}
|
||||
|
||||
downloadManager
|
||||
.getStatusNotifier(track as SourcedTrack)
|
||||
?.addListener(listener);
|
||||
notifier?.addListener(listener);
|
||||
|
||||
return () {
|
||||
downloadManager
|
||||
.getStatusNotifier(track as SourcedTrack)
|
||||
?.removeListener(listener);
|
||||
notifier?.removeListener(listener);
|
||||
};
|
||||
}, [track]);
|
||||
|
||||
final isQueryingSourceInfo =
|
||||
taskStatus.value == null || track is! SourcedTrack;
|
||||
|
||||
return ListTile(
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||
@ -63,7 +63,7 @@ class DownloadItem extends HookConsumerWidget {
|
||||
track.artists ?? <Artist>[],
|
||||
mainAxisAlignment: WrapAlignment.start,
|
||||
),
|
||||
trailing: taskStatus.value == null || track is! SourcedTrack
|
||||
trailing: isQueryingSourceInfo
|
||||
? Text(
|
||||
context.l10n.querying_info,
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
|
||||
@ -141,9 +141,9 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
bool isActive(Track track) {
|
||||
if ($backHistory.contains(track)) return true;
|
||||
|
||||
final SourcedTrack = mapToSourcedTrack(track);
|
||||
final sourcedTrack = mapToSourcedTrack(track);
|
||||
|
||||
if (SourcedTrack == null) return false;
|
||||
if (sourcedTrack == null) return false;
|
||||
|
||||
return dl
|
||||
.getAllDownloads()
|
||||
@ -154,7 +154,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
download.status.value == DownloadStatus.queued,
|
||||
)
|
||||
.map((e) => e.request.url)
|
||||
.contains(SourcedTrack.url);
|
||||
.contains(sourcedTrack.getUrlOfCodec(downloadCodec));
|
||||
}
|
||||
|
||||
/// For singular downloads
|
||||
@ -171,7 +171,8 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
if (track is SourcedTrack && track.codec == downloadCodec) {
|
||||
final downloadTask = await dl.addDownload(track.url, savePath);
|
||||
final downloadTask =
|
||||
await dl.addDownload(track.getUrlOfCodec(downloadCodec), savePath);
|
||||
if (downloadTask != null) {
|
||||
$history.add(track);
|
||||
}
|
||||
@ -219,16 +220,16 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> removeFromQueue(SourcedTrack track) async {
|
||||
await dl.removeDownload(track.url);
|
||||
await dl.removeDownload(track.getUrlOfCodec(downloadCodec));
|
||||
$history.remove(track);
|
||||
}
|
||||
|
||||
Future<void> pause(SourcedTrack track) {
|
||||
return dl.pauseDownload(track.url);
|
||||
return dl.pauseDownload(track.getUrlOfCodec(downloadCodec));
|
||||
}
|
||||
|
||||
Future<void> resume(SourcedTrack track) {
|
||||
return dl.resumeDownload(track.url);
|
||||
return dl.resumeDownload(track.getUrlOfCodec(downloadCodec));
|
||||
}
|
||||
|
||||
Future<void> retry(SourcedTrack track) {
|
||||
@ -236,7 +237,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
void cancel(SourcedTrack track) {
|
||||
dl.cancelDownload(track.url);
|
||||
dl.cancelDownload(track.getUrlOfCodec(downloadCodec));
|
||||
}
|
||||
|
||||
void cancelAll() {
|
||||
@ -255,11 +256,11 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
ValueNotifier<DownloadStatus>? getStatusNotifier(SourcedTrack track) {
|
||||
return dl.getDownload(track.url)?.status;
|
||||
return dl.getDownload(track.getUrlOfCodec(downloadCodec))?.status;
|
||||
}
|
||||
|
||||
ValueNotifier<double>? getProgressNotifier(SourcedTrack track) {
|
||||
return dl.getDownload(track.url)?.progress;
|
||||
return dl.getDownload(track.getUrlOfCodec(downloadCodec))?.progress;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user