mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-10 09:07:29 +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);
|
final notifier = downloadManager.getStatusNotifier(track as SourcedTrack);
|
||||||
|
|
||||||
taskStatus.value = notifier?.value;
|
taskStatus.value = notifier?.value;
|
||||||
listener() {
|
|
||||||
|
void listener() {
|
||||||
taskStatus.value = notifier?.value;
|
taskStatus.value = notifier?.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadManager
|
notifier?.addListener(listener);
|
||||||
.getStatusNotifier(track as SourcedTrack)
|
|
||||||
?.addListener(listener);
|
|
||||||
|
|
||||||
return () {
|
return () {
|
||||||
downloadManager
|
notifier?.removeListener(listener);
|
||||||
.getStatusNotifier(track as SourcedTrack)
|
|
||||||
?.removeListener(listener);
|
|
||||||
};
|
};
|
||||||
}, [track]);
|
}, [track]);
|
||||||
|
|
||||||
|
final isQueryingSourceInfo =
|
||||||
|
taskStatus.value == null || track is! SourcedTrack;
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: Padding(
|
leading: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 5),
|
padding: const EdgeInsets.symmetric(horizontal: 5),
|
||||||
@ -63,7 +63,7 @@ class DownloadItem extends HookConsumerWidget {
|
|||||||
track.artists ?? <Artist>[],
|
track.artists ?? <Artist>[],
|
||||||
mainAxisAlignment: WrapAlignment.start,
|
mainAxisAlignment: WrapAlignment.start,
|
||||||
),
|
),
|
||||||
trailing: taskStatus.value == null || track is! SourcedTrack
|
trailing: isQueryingSourceInfo
|
||||||
? Text(
|
? Text(
|
||||||
context.l10n.querying_info,
|
context.l10n.querying_info,
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
style: Theme.of(context).textTheme.labelMedium,
|
||||||
|
|||||||
@ -141,9 +141,9 @@ class DownloadManagerProvider extends ChangeNotifier {
|
|||||||
bool isActive(Track track) {
|
bool isActive(Track track) {
|
||||||
if ($backHistory.contains(track)) return true;
|
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
|
return dl
|
||||||
.getAllDownloads()
|
.getAllDownloads()
|
||||||
@ -154,7 +154,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
|||||||
download.status.value == DownloadStatus.queued,
|
download.status.value == DownloadStatus.queued,
|
||||||
)
|
)
|
||||||
.map((e) => e.request.url)
|
.map((e) => e.request.url)
|
||||||
.contains(SourcedTrack.url);
|
.contains(sourcedTrack.getUrlOfCodec(downloadCodec));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For singular downloads
|
/// For singular downloads
|
||||||
@ -171,7 +171,8 @@ class DownloadManagerProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (track is SourcedTrack && track.codec == downloadCodec) {
|
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) {
|
if (downloadTask != null) {
|
||||||
$history.add(track);
|
$history.add(track);
|
||||||
}
|
}
|
||||||
@ -219,16 +220,16 @@ class DownloadManagerProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> removeFromQueue(SourcedTrack track) async {
|
Future<void> removeFromQueue(SourcedTrack track) async {
|
||||||
await dl.removeDownload(track.url);
|
await dl.removeDownload(track.getUrlOfCodec(downloadCodec));
|
||||||
$history.remove(track);
|
$history.remove(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> pause(SourcedTrack track) {
|
Future<void> pause(SourcedTrack track) {
|
||||||
return dl.pauseDownload(track.url);
|
return dl.pauseDownload(track.getUrlOfCodec(downloadCodec));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> resume(SourcedTrack track) {
|
Future<void> resume(SourcedTrack track) {
|
||||||
return dl.resumeDownload(track.url);
|
return dl.resumeDownload(track.getUrlOfCodec(downloadCodec));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> retry(SourcedTrack track) {
|
Future<void> retry(SourcedTrack track) {
|
||||||
@ -236,7 +237,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cancel(SourcedTrack track) {
|
void cancel(SourcedTrack track) {
|
||||||
dl.cancelDownload(track.url);
|
dl.cancelDownload(track.getUrlOfCodec(downloadCodec));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelAll() {
|
void cancelAll() {
|
||||||
@ -255,11 +256,11 @@ class DownloadManagerProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ValueNotifier<DownloadStatus>? getStatusNotifier(SourcedTrack track) {
|
ValueNotifier<DownloadStatus>? getStatusNotifier(SourcedTrack track) {
|
||||||
return dl.getDownload(track.url)?.status;
|
return dl.getDownload(track.getUrlOfCodec(downloadCodec))?.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueNotifier<double>? getProgressNotifier(SourcedTrack track) {
|
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