mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: local tracks getting fetched on first load
This commit is contained in:
parent
ea45c4f42a
commit
73c012c71a
@ -95,7 +95,7 @@ final localTracksProvider = FutureProvider<List<LocalTrack>>((ref) async {
|
||||
return {"metadata": metadata, "file": f, "art": imageFile.path};
|
||||
} catch (e, stack) {
|
||||
if (e is FfiException) {
|
||||
return {};
|
||||
return {"file": f};
|
||||
}
|
||||
Catcher.reportCheckedError(e, stack);
|
||||
return {};
|
||||
|
@ -22,7 +22,7 @@ import 'package:spotube/utils/type_conversion_utils.dart';
|
||||
/// Things to implement:
|
||||
/// * [x] Sponsor-Block skip
|
||||
/// * [x] Prefetch next track as [SpotubeTrack] on 80% of current track
|
||||
/// * [ ] Mixed Queue containing both [SpotubeTrack] and [LocalTrack]
|
||||
/// * [x] Mixed Queue containing both [SpotubeTrack] and [LocalTrack]
|
||||
/// * [ ] Modification of the Queue
|
||||
/// * [x] Add track at the end
|
||||
/// * [x] Add track at the beginning
|
||||
@ -218,29 +218,37 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier<ProxyPlaylist>
|
||||
bool autoPlay = false,
|
||||
}) async {
|
||||
tracks = blacklist.filter(tracks).toList() as List<Track>;
|
||||
final addableTrack = await SpotubeTrack.fetchFromTrack(
|
||||
tracks.elementAtOrNull(initialIndex) ?? tracks.first,
|
||||
preferences,
|
||||
pipedClient,
|
||||
);
|
||||
final indexTrack = tracks.elementAtOrNull(initialIndex) ?? tracks.first;
|
||||
|
||||
state = state.copyWith(
|
||||
tracks: mergeTracks([addableTrack], tracks),
|
||||
active: initialIndex,
|
||||
);
|
||||
if (indexTrack is LocalTrack) {
|
||||
state = state.copyWith(
|
||||
tracks: tracks.toSet(),
|
||||
active: initialIndex,
|
||||
);
|
||||
await notificationService.addTrack(indexTrack);
|
||||
} else {
|
||||
final addableTrack = await SpotubeTrack.fetchFromTrack(
|
||||
tracks.elementAtOrNull(initialIndex) ?? tracks.first,
|
||||
preferences,
|
||||
pipedClient,
|
||||
);
|
||||
|
||||
await notificationService.addTrack(addableTrack);
|
||||
state = state.copyWith(
|
||||
tracks: mergeTracks([addableTrack], tracks),
|
||||
active: initialIndex,
|
||||
);
|
||||
await notificationService.addTrack(addableTrack);
|
||||
await storeTrack(
|
||||
tracks.elementAt(initialIndex),
|
||||
addableTrack,
|
||||
);
|
||||
}
|
||||
|
||||
await audioPlayer.openPlaylist(
|
||||
state.tracks.map(makeAppropriateSource).toList(),
|
||||
initialIndex: initialIndex,
|
||||
autoPlay: autoPlay,
|
||||
);
|
||||
|
||||
await storeTrack(
|
||||
tracks.elementAt(initialIndex),
|
||||
addableTrack,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> jumpTo(int index) async {
|
||||
|
@ -323,7 +323,7 @@ class _MprisMediaPlayer2Player extends DBusObject {
|
||||
"xesam:url": DBusString(
|
||||
playlist.activeTrack is SpotubeTrack
|
||||
? (playlist.activeTrack as SpotubeTrack).ytUri
|
||||
: playlist.activeTrack!.previewUrl!,
|
||||
: playlist.activeTrack!.previewUrl ?? "",
|
||||
),
|
||||
"xesam:genre": const DBusString("Unknown"),
|
||||
}),
|
||||
|
Loading…
Reference in New Issue
Block a user