mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
feat: track populate sibling support
This commit is contained in:
parent
96f04c1756
commit
3aeb026776
@ -304,8 +304,38 @@ class ProxyPlaylistNotifier extends PersistedStateNotifier<ProxyPlaylist>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> populateSibling() async {}
|
Future<void> populateSibling() async {
|
||||||
Future<void> swapSibling(PipedSearchItem video) async {}
|
if (state.activeTrack is SpotubeTrack) {
|
||||||
|
final activeTrackWithSiblingsForSure =
|
||||||
|
await (state.activeTrack as SpotubeTrack).populatedCopy();
|
||||||
|
|
||||||
|
state = state.copyWith(
|
||||||
|
tracks: mergeTracks([activeTrackWithSiblingsForSure], state.tracks),
|
||||||
|
active: state.tracks.toList().indexWhere(
|
||||||
|
(element) => element.id == activeTrackWithSiblingsForSure.id),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> swapSibling(PipedSearchItem video) async {
|
||||||
|
if (state.activeTrack is SpotubeTrack && video is PipedSearchItemStream) {
|
||||||
|
populateSibling();
|
||||||
|
final newTrack = await (state.activeTrack as SpotubeTrack)
|
||||||
|
.swappedCopy(video, preferences);
|
||||||
|
if (newTrack == null) return;
|
||||||
|
state = state.copyWith(
|
||||||
|
tracks: mergeTracks([newTrack], state.tracks),
|
||||||
|
active: state.tracks
|
||||||
|
.toList()
|
||||||
|
.indexWhere((element) => element.id == newTrack.id),
|
||||||
|
);
|
||||||
|
await audioPlayer.pause();
|
||||||
|
await audioPlayer.replaceSource(
|
||||||
|
audioPlayer.currentSource!,
|
||||||
|
makeAppropriateSource(newTrack),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> next() async {
|
Future<void> next() async {
|
||||||
if (audioPlayer.nextSource == null) return;
|
if (audioPlayer.nextSource == null) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user