mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 14:37:06 +01:00
Add 'byData' as playqueue add option
This commit is contained in:
parent
0edba7e222
commit
8ebe882236
@ -10,6 +10,7 @@ import { usePlayerType } from '/@/renderer/store/settings.store';
|
||||
import { PlayQueueAddOptions, LibraryItem, Play, PlaybackType } from '/@/renderer/types';
|
||||
import { toast } from '/@/renderer/components/toast';
|
||||
import isElectron from 'is-electron';
|
||||
import { nanoid } from 'nanoid/non-secure';
|
||||
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
|
||||
@ -74,6 +75,29 @@ export const useHandlePlayQueueAdd = () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.byData) {
|
||||
const songsWithNewUniqueId = options.byData.map((song) => ({ ...song, uniqueId: nanoid() }));
|
||||
|
||||
const playerData = usePlayerStore
|
||||
.getState()
|
||||
.actions.addToQueue(songsWithNewUniqueId, options.play);
|
||||
|
||||
if (options.play === Play.NEXT || options.play === Play.LAST) {
|
||||
if (playerType === PlaybackType.LOCAL) {
|
||||
mpvPlayer.setQueueNext(playerData);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.play === Play.NOW) {
|
||||
if (playerType === PlaybackType.LOCAL) {
|
||||
mpvPlayer.setQueue(playerData);
|
||||
mpvPlayer.play();
|
||||
}
|
||||
|
||||
usePlayerStore.getState().actions.play();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Album, AlbumArtist, Artist } from '/@/renderer/api/types';
|
||||
import { Album, AlbumArtist, Artist, QueueSong } from '/@/renderer/api/types';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
|
||||
export type TablePagination = {
|
||||
@ -157,8 +157,8 @@ export enum TableColumn {
|
||||
}
|
||||
|
||||
export type PlayQueueAddOptions = {
|
||||
// byData?: any[];
|
||||
byItemType: {
|
||||
byData?: QueueSong[];
|
||||
byItemType?: {
|
||||
id: string;
|
||||
type: LibraryItem;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user