mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
Move types up
This commit is contained in:
@@ -10,10 +10,10 @@ import {
|
||||
RiSkipBackFill,
|
||||
RiSkipForwardFill,
|
||||
} from 'react-icons/ri';
|
||||
import { PlaybackType, PlayerStatus } from '../../../../types';
|
||||
import { Text } from '../../../components';
|
||||
import { usePlayerStore } from '../../../store';
|
||||
import { Font } from '../../../styles';
|
||||
import { Text } from '@/renderer/components';
|
||||
import { usePlayerStore } from '@/renderer/store';
|
||||
import { Font } from '@/renderer/styles';
|
||||
import { PlaybackType, PlayerStatus } from '@/renderer/types';
|
||||
import { useCenterControls } from '../hooks/use-center-controls';
|
||||
import { PlayerButton } from './player-button';
|
||||
import { Slider } from './slider';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback } from 'react';
|
||||
import { PlaybackType, PlayerStatus } from '../../../../types';
|
||||
import { PlaybackType, PlayerStatus } from '@/renderer/types';
|
||||
import { usePlayerStore } from '../../../store';
|
||||
import { mpvPlayer } from '../utils/mpvPlayer';
|
||||
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import { api } from '@/renderer/api';
|
||||
import { Item, Play } from '../../../../types';
|
||||
import { LibraryItem, Play } from '@/renderer/types';
|
||||
import { useAuthStore, usePlayerStore } from '../../../store';
|
||||
import { mpvPlayer } from '../utils/mpvPlayer';
|
||||
|
||||
const getEndpointByItemType = (item: Item) => {
|
||||
switch (item) {
|
||||
case Item.ALBUM:
|
||||
return api.albums.getAlbumDetail;
|
||||
default:
|
||||
return api.albums.getAlbumDetail;
|
||||
}
|
||||
};
|
||||
|
||||
export const usePlayQueueHandler = () => {
|
||||
const serverId = useAuthStore((state) => state.currentServer?.id) || '';
|
||||
const addToQueue = usePlayerStore((state) => state.addToQueue);
|
||||
@@ -19,9 +10,8 @@ export const usePlayQueueHandler = () => {
|
||||
const handlePlayQueueAdd = async (options: {
|
||||
byData?: any[];
|
||||
byItemType?: {
|
||||
endpoint: (params: Record<string, any>) => any;
|
||||
id: number;
|
||||
type: Item;
|
||||
type: LibraryItem;
|
||||
};
|
||||
play: Play;
|
||||
}) => {
|
||||
@@ -35,44 +25,54 @@ export const usePlayQueueHandler = () => {
|
||||
// localStorage.getItem('authentication') || '{}'
|
||||
// );
|
||||
|
||||
if (deviceId) {
|
||||
const endpoint = getEndpointByItemType(options.byItemType.type);
|
||||
if (!deviceId) return;
|
||||
|
||||
const { data } = await endpoint({
|
||||
let songs = null;
|
||||
if (options.byItemType.type === LibraryItem.ALBUM) {
|
||||
const { data } = await api.albums.getAlbumDetail({
|
||||
albumId: options.byItemType.id,
|
||||
serverId,
|
||||
});
|
||||
|
||||
const songs = data.songs?.map((song) => {
|
||||
// const auth = getServerFolderAuth(
|
||||
// state.serverUrl,
|
||||
// song.serverFolderId
|
||||
// );
|
||||
songs = data.songs;
|
||||
}
|
||||
|
||||
// if (auth) {
|
||||
// const streamUrl =
|
||||
// auth.type === 'jellyfin'
|
||||
// ? getJellyfinStreamUrl(auth, song, deviceId)
|
||||
// : getSubsonicStreamUrl(auth, song, deviceId);
|
||||
// const endpoint = getEndpointByItemType(options.byItemType.type);
|
||||
|
||||
// return {
|
||||
// ...song,
|
||||
// streamUrl,
|
||||
// };
|
||||
// }
|
||||
// const { data } = await endpoint({
|
||||
// albumId: options.byItemType.id,
|
||||
// serverId,
|
||||
// });
|
||||
|
||||
return song;
|
||||
});
|
||||
// const songs = data.songs?.map((song) => {
|
||||
// const auth = getServerFolderAuth(
|
||||
// state.serverUrl,
|
||||
// song.serverFolderId
|
||||
// );
|
||||
|
||||
const playerData = addToQueue(songs || [], options.play);
|
||||
// if (auth) {
|
||||
// const streamUrl =
|
||||
// auth.type === 'jellyfin'
|
||||
// ? getJellyfinStreamUrl(auth, song, deviceId)
|
||||
// : getSubsonicStreamUrl(auth, song, deviceId);
|
||||
|
||||
console.log('playerData', playerData);
|
||||
// return {
|
||||
// ...song,
|
||||
// streamUrl,
|
||||
// };
|
||||
// }
|
||||
|
||||
if (options.play === Play.NEXT || options.play === Play.LAST) {
|
||||
mpvPlayer.setQueueNext(playerData);
|
||||
} else {
|
||||
mpvPlayer.setQueue(playerData);
|
||||
}
|
||||
// return song;
|
||||
// });
|
||||
|
||||
if (!songs) return;
|
||||
|
||||
const playerData = addToQueue(songs, options.play);
|
||||
|
||||
if (options.play === Play.NEXT || options.play === Play.LAST) {
|
||||
mpvPlayer.setQueueNext(playerData);
|
||||
} else {
|
||||
mpvPlayer.setQueue(playerData);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import {
|
||||
PlaybackStyle,
|
||||
PlaybackType,
|
||||
PlayerRepeat,
|
||||
} from '../../../../types';
|
||||
} from '@/renderer/types';
|
||||
import { PlayerState } from '../../../store';
|
||||
|
||||
export interface WebSettings {
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
PlayerRepeat,
|
||||
PlayerStatus,
|
||||
UniqueId,
|
||||
} from '../../types';
|
||||
} from '@/renderer/types';
|
||||
|
||||
type QueueSong = Song & UniqueId;
|
||||
|
||||
|
||||
@@ -8,3 +8,68 @@ export interface CardRow {
|
||||
route: AppRoute | string;
|
||||
};
|
||||
}
|
||||
|
||||
export enum LibraryItem {
|
||||
ALBUM = 'album',
|
||||
ALBUM_ARTIST = 'albumArtist',
|
||||
ARTIST = 'artist',
|
||||
PLAYLIST = 'playlist',
|
||||
SONG = 'song',
|
||||
}
|
||||
|
||||
export enum Platform {
|
||||
LINUX = 'linux',
|
||||
MACOS = 'macos',
|
||||
WEB = 'web',
|
||||
WINDOWS = 'windows',
|
||||
}
|
||||
|
||||
export enum ServerType {
|
||||
JELLYFIN = 'jellyfin',
|
||||
SUBSONIC = 'subsonic',
|
||||
}
|
||||
|
||||
export enum PlayerStatus {
|
||||
PAUSED = 'paused',
|
||||
PLAYING = 'playing',
|
||||
}
|
||||
|
||||
export enum PlayerRepeat {
|
||||
ALL = 'all',
|
||||
NONE = 'none',
|
||||
ONE = 'one',
|
||||
}
|
||||
|
||||
export enum Play {
|
||||
LAST = 'last',
|
||||
NEXT = 'next',
|
||||
NOW = 'now',
|
||||
}
|
||||
|
||||
export enum CrossfadeStyle {
|
||||
CONSTANT_POWER = 'constantPower',
|
||||
CONSTANT_POWER_SLOW_CUT = 'constantPowerSlowCut',
|
||||
CONSTANT_POWER_SLOW_FADE = 'constantPowerSlowFade',
|
||||
DIPPED = 'dipped',
|
||||
EQUALPOWER = 'equalPower',
|
||||
LINEAR = 'linear',
|
||||
}
|
||||
|
||||
export enum PlaybackStyle {
|
||||
CROSSFADE = 'crossfade',
|
||||
GAPLESS = 'gapless',
|
||||
}
|
||||
|
||||
export enum PlaybackType {
|
||||
LOCAL = 'local',
|
||||
WEB = 'web',
|
||||
}
|
||||
|
||||
export interface UniqueId {
|
||||
uniqueId: string;
|
||||
}
|
||||
|
||||
export enum SortOrder {
|
||||
ASC = 'asc',
|
||||
DESC = 'desc',
|
||||
}
|
||||
|
||||
-202
@@ -1,202 +0,0 @@
|
||||
export enum Platform {
|
||||
LINUX = 'linux',
|
||||
MACOS = 'macos',
|
||||
WEB = 'web',
|
||||
WINDOWS = 'windows',
|
||||
}
|
||||
|
||||
export enum ServerType {
|
||||
JELLYFIN = 'jellyfin',
|
||||
SUBSONIC = 'subsonic',
|
||||
}
|
||||
|
||||
export enum Item {
|
||||
ALBUM = 'album',
|
||||
ALBUM_ARTIST = 'albumArtist',
|
||||
ARTIST = 'artist',
|
||||
FOLDER = 'folder',
|
||||
GENRE = 'genre',
|
||||
PLAYLIST = 'playlist',
|
||||
SONG = 'song',
|
||||
}
|
||||
|
||||
export enum PlayerStatus {
|
||||
PAUSED = 'paused',
|
||||
PLAYING = 'playing',
|
||||
}
|
||||
|
||||
export enum PlayerRepeat {
|
||||
ALL = 'all',
|
||||
NONE = 'none',
|
||||
ONE = 'one',
|
||||
}
|
||||
|
||||
export enum Play {
|
||||
LAST = 'last',
|
||||
NEXT = 'next',
|
||||
NOW = 'now',
|
||||
}
|
||||
|
||||
export enum CrossfadeStyle {
|
||||
CONSTANT_POWER = 'constantPower',
|
||||
CONSTANT_POWER_SLOW_CUT = 'constantPowerSlowCut',
|
||||
CONSTANT_POWER_SLOW_FADE = 'constantPowerSlowFade',
|
||||
DIPPED = 'dipped',
|
||||
EQUALPOWER = 'equalPower',
|
||||
LINEAR = 'linear',
|
||||
}
|
||||
|
||||
export enum PlaybackStyle {
|
||||
CROSSFADE = 'crossfade',
|
||||
GAPLESS = 'gapless',
|
||||
}
|
||||
|
||||
export enum PlaybackType {
|
||||
LOCAL = 'local',
|
||||
WEB = 'web',
|
||||
}
|
||||
|
||||
export type APIEndpoints =
|
||||
| 'getPlaylist'
|
||||
| 'getPlaylists'
|
||||
| 'getStarred'
|
||||
| 'getAlbum'
|
||||
| 'getAlbums'
|
||||
| 'getRandomSongs'
|
||||
| 'getArtist'
|
||||
| 'getArtists'
|
||||
| 'getArtistInfo'
|
||||
| 'getArtistSongs'
|
||||
| 'startScan'
|
||||
| 'getScanStatus'
|
||||
| 'star'
|
||||
| 'unstar'
|
||||
| 'batchStar'
|
||||
| 'batchUnstar'
|
||||
| 'setRating'
|
||||
| 'getSimilarSongs'
|
||||
| 'updatePlaylistSongs'
|
||||
| 'updatePlaylistSongsLg'
|
||||
| 'deletePlaylist'
|
||||
| 'createPlaylist'
|
||||
| 'updatePlaylist'
|
||||
| 'updatePlaylistSongsLg'
|
||||
| 'deletePlaylist'
|
||||
| 'createPlaylist'
|
||||
| 'updatePlaylist'
|
||||
| 'clearPlaylist'
|
||||
| 'getGenres'
|
||||
| 'getSearch'
|
||||
| 'scrobble'
|
||||
| 'getIndexes'
|
||||
| 'getMusicFolders'
|
||||
| 'getMusicDirectory'
|
||||
| 'getMusicDirectorySongs'
|
||||
| 'getDownloadUrl'
|
||||
| 'getSongs'
|
||||
| 'getTopSongs'
|
||||
| 'getSongsByGenre'
|
||||
| 'getLyrics';
|
||||
|
||||
export interface APIResult {
|
||||
data: Album[] | Artist[] | Genre[] | Song[];
|
||||
totalRecordCount?: number;
|
||||
}
|
||||
|
||||
interface RelatedItem {
|
||||
deleted?: boolean;
|
||||
id: string;
|
||||
name: string;
|
||||
remoteId?: string;
|
||||
}
|
||||
|
||||
export interface Album {
|
||||
albumArtist: AlbumArtist;
|
||||
averageRating: number;
|
||||
container: string;
|
||||
createdAt: string;
|
||||
date: string;
|
||||
deleted: boolean;
|
||||
genres: RelatedItem[];
|
||||
id: number;
|
||||
imageUrl: string;
|
||||
name: string;
|
||||
rating: number;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverFolderId: number;
|
||||
serverType: ServerType | string;
|
||||
songCount: number;
|
||||
songs: Song[];
|
||||
updatedAt: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
export interface AlbumArtist {
|
||||
biography?: string;
|
||||
createdAt: string;
|
||||
deleted: boolean;
|
||||
id: number;
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverId: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface Artist {
|
||||
biography?: string;
|
||||
createdAt: string;
|
||||
deleted: boolean;
|
||||
id: number;
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverId: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface Genre {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Song {
|
||||
album: RelatedItem;
|
||||
artistName: null;
|
||||
artists: RelatedItem[];
|
||||
bitRate: number;
|
||||
container: string;
|
||||
createdAt: string;
|
||||
date: string;
|
||||
deleted: boolean;
|
||||
disc: number;
|
||||
duration: number;
|
||||
genres: RelatedItem[];
|
||||
id: number;
|
||||
imageUrl: string;
|
||||
name: string;
|
||||
remoteCreatedAt: string;
|
||||
remoteId: string;
|
||||
serverFolderId: number;
|
||||
serverId: number;
|
||||
streamUrl: string;
|
||||
track: number;
|
||||
updatedAt: string;
|
||||
year: number;
|
||||
}
|
||||
|
||||
export interface ServerFolderAuth {
|
||||
id: number;
|
||||
locked: boolean;
|
||||
serverId: number;
|
||||
token: string;
|
||||
type: string;
|
||||
url: string;
|
||||
userId: string;
|
||||
username: string;
|
||||
}
|
||||
|
||||
export interface UniqueId {
|
||||
uniqueId: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user