mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-05 23:19:42 +00:00
Merge 686638a918 into 826c8e4dd6
This commit is contained in:
commit
ac3714f344
@ -89,7 +89,7 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isInQueue) ...[
|
if (!isInQueue)
|
||||||
ButtonTile(
|
ButtonTile(
|
||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@ -102,21 +102,8 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
leading: const Icon(SpotubeIcons.queueAdd),
|
leading: const Icon(SpotubeIcons.queueAdd),
|
||||||
title: Text(context.l10n.add_to_queue),
|
title: Text(context.l10n.add_to_queue),
|
||||||
),
|
)
|
||||||
ButtonTile(
|
else
|
||||||
style: ButtonVariance.menu,
|
|
||||||
onPressed: () async {
|
|
||||||
await trackOptionActions.action(
|
|
||||||
rootNavigatorKey.currentContext!,
|
|
||||||
TrackOptionValue.playNext,
|
|
||||||
playlistId,
|
|
||||||
);
|
|
||||||
onTapItem?.call();
|
|
||||||
},
|
|
||||||
leading: const Icon(SpotubeIcons.lightning),
|
|
||||||
title: Text(context.l10n.play_next),
|
|
||||||
),
|
|
||||||
] else
|
|
||||||
ButtonTile(
|
ButtonTile(
|
||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@ -131,6 +118,19 @@ class TrackOptions extends HookConsumerWidget {
|
|||||||
leading: const Icon(SpotubeIcons.queueRemove),
|
leading: const Icon(SpotubeIcons.queueRemove),
|
||||||
title: Text(context.l10n.remove_from_queue),
|
title: Text(context.l10n.remove_from_queue),
|
||||||
),
|
),
|
||||||
|
ButtonTile(
|
||||||
|
style: ButtonVariance.menu,
|
||||||
|
onPressed: () async {
|
||||||
|
await trackOptionActions.action(
|
||||||
|
rootNavigatorKey.currentContext!,
|
||||||
|
TrackOptionValue.playNext,
|
||||||
|
playlistId,
|
||||||
|
);
|
||||||
|
onTapItem?.call();
|
||||||
|
},
|
||||||
|
leading: const Icon(SpotubeIcons.lightning),
|
||||||
|
title: Text(context.l10n.play_next),
|
||||||
|
),
|
||||||
if (isAuthenticated && !isLocalTrack)
|
if (isAuthenticated && !isLocalTrack)
|
||||||
ButtonTile(
|
ButtonTile(
|
||||||
style: ButtonVariance.menu,
|
style: ButtonVariance.menu,
|
||||||
|
|||||||
@ -228,24 +228,32 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
|
|||||||
|
|
||||||
final addableTracks = _blacklist
|
final addableTracks = _blacklist
|
||||||
.filter(tracks)
|
.filter(tracks)
|
||||||
.where(
|
|
||||||
(track) =>
|
|
||||||
allowDuplicates ||
|
|
||||||
!state.tracks.any((element) => _compareTracks(element, track)),
|
|
||||||
)
|
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
state = state.copyWith(
|
|
||||||
tracks: [...addableTracks, ...state.tracks],
|
|
||||||
);
|
|
||||||
|
|
||||||
for (int i = 0; i < addableTracks.length; i++) {
|
for (int i = 0; i < addableTracks.length; i++) {
|
||||||
final track = addableTracks.elementAt(i);
|
final track = addableTracks.elementAt(i);
|
||||||
|
|
||||||
await audioPlayer.addTrackAt(
|
final (currentTrackIndex, _) = state.tracks
|
||||||
SpotubeMedia(track),
|
.indexed
|
||||||
max(state.currentIndex, 0) + i + 1,
|
.cast<(int, SpotubeTrackObject?)>()
|
||||||
);
|
.firstWhere(
|
||||||
|
(record) {
|
||||||
|
final (idx, element) = record;
|
||||||
|
return _compareTracks(element!, track);
|
||||||
|
},
|
||||||
|
orElse: () => (-1, null)
|
||||||
|
);
|
||||||
|
|
||||||
|
final newIndex = max(state.currentIndex, 0) + i + 1;
|
||||||
|
|
||||||
|
if (allowDuplicates || currentTrackIndex < 0) {
|
||||||
|
await audioPlayer.addTrackAt(
|
||||||
|
SpotubeMedia(track),
|
||||||
|
newIndex
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await audioPlayer.moveTrack(currentTrackIndex, newIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await _updatePlayerState(
|
await _updatePlayerState(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user