mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00

* refactor: remove SourcedTrack based audio player and utilize mediakit playback system * feat: implement local (loopback) server to resolve stream source and leverage the media_kit playback API * feat: add source change support and re-add prefetching tracks * fix: assign lastId when track fetch completes regardless of error * chore: remove print statements * fix: remote queue not working * fix: increase mpv network timeout to reduce auto-skipping * fix: do not pre-fetch local tracks * fix(proxy-playlist): reset collections on load * chore: fix lint warnings * fix(mobile): player overlay should not be visible when the player is not playing * chore: fix typo in turkish translation * cd: checkout PR branch * cd: upgrade flutter version * chore: fix lint errors
36 lines
925 B
Dart
36 lines
925 B
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:spotube/services/download_manager/download_request.dart';
|
|
import 'package:spotube/services/download_manager/download_status.dart';
|
|
|
|
class DownloadTask {
|
|
final DownloadRequest request;
|
|
ValueNotifier<DownloadStatus> status = ValueNotifier(DownloadStatus.queued);
|
|
ValueNotifier<double> progress = ValueNotifier(0);
|
|
|
|
DownloadTask(
|
|
this.request,
|
|
);
|
|
|
|
Future<DownloadStatus> whenDownloadComplete(
|
|
{Duration timeout = const Duration(hours: 2)}) async {
|
|
var completer = Completer<DownloadStatus>();
|
|
|
|
if (status.value.isCompleted) {
|
|
completer.complete(status.value);
|
|
}
|
|
|
|
void listener() {
|
|
if (status.value.isCompleted) {
|
|
completer.complete(status.value);
|
|
status.removeListener(listener);
|
|
}
|
|
}
|
|
|
|
status.addListener(listener);
|
|
|
|
return completer.future.timeout(timeout);
|
|
}
|
|
}
|