mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 20:40:21 +02:00
feat: sync play queue for navidrome/subsonic (#1335)
--------- Co-authored-by: jeffvli <jeffvictorli@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
subscribePlayerStatus,
|
||||
subscribePlayerVolume,
|
||||
} from '/@/renderer/store';
|
||||
import { LibraryItem, QueueData, QueueSong } from '/@/shared/types/domain-types';
|
||||
import { LibraryItem, QueueData, QueueSong, Song } from '/@/shared/types/domain-types';
|
||||
import { PlayerRepeat, PlayerShuffle, PlayerStatus } from '/@/shared/types/types';
|
||||
|
||||
interface PlayerEvents {
|
||||
@@ -46,6 +46,7 @@ interface PlayerEventsCallbacks {
|
||||
onPlayerSpeed?: (properties: { speed: number }, prev: { speed: number }) => void;
|
||||
onPlayerStatus?: (properties: { status: PlayerStatus }, prev: { status: PlayerStatus }) => void;
|
||||
onPlayerVolume?: (properties: { volume: number }, prev: { volume: number }) => void;
|
||||
onQueueRestored?: (properties: { data: Song[]; index: number; position: number }) => void;
|
||||
onUserFavorite?: (properties: {
|
||||
favorite: boolean;
|
||||
id: string[];
|
||||
@@ -152,6 +153,10 @@ function createPlayerEvents(callbacks: PlayerEventsCallbacks): PlayerEvents {
|
||||
eventEmitter.on('PLAYER_PLAY', callbacks.onPlayerPlay);
|
||||
}
|
||||
|
||||
if (callbacks.onQueueRestored) {
|
||||
eventEmitter.on('QUEUE_RESTORED', callbacks.onQueueRestored);
|
||||
}
|
||||
|
||||
if (callbacks.onUserFavorite) {
|
||||
eventEmitter.on('USER_FAVORITE', callbacks.onUserFavorite);
|
||||
}
|
||||
@@ -172,6 +177,9 @@ function createPlayerEvents(callbacks: PlayerEventsCallbacks): PlayerEvents {
|
||||
if (callbacks.onPlayerPlay) {
|
||||
eventEmitter.off('PLAYER_PLAY', callbacks.onPlayerPlay);
|
||||
}
|
||||
if (callbacks.onQueueRestored) {
|
||||
eventEmitter.off('QUEUE_RESTORED', callbacks.onQueueRestored);
|
||||
}
|
||||
if (callbacks.onUserFavorite) {
|
||||
eventEmitter.off('USER_FAVORITE', callbacks.onUserFavorite);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user