mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
Normalize types
This commit is contained in:
@@ -154,14 +154,14 @@ export const AudioPlayer = forwardRef(
|
|||||||
ref={player1Ref}
|
ref={player1Ref}
|
||||||
height={0}
|
height={0}
|
||||||
muted={muted}
|
muted={muted}
|
||||||
playing={currentPlayer === 1 && status === PlayerStatus.Playing}
|
playing={currentPlayer === 1 && status === PlayerStatus.PLAYING}
|
||||||
progressInterval={isTransitioning ? 10 : 250}
|
progressInterval={isTransitioning ? 10 : 250}
|
||||||
url={player1?.streamUrl}
|
url={player1?.streamUrl}
|
||||||
volume={volume}
|
volume={volume}
|
||||||
width={0}
|
width={0}
|
||||||
onEnded={handleOnEnded}
|
onEnded={handleOnEnded}
|
||||||
onProgress={
|
onProgress={
|
||||||
playbackStyle === PlaybackStyle.Gapless
|
playbackStyle === PlaybackStyle.GAPLESS
|
||||||
? handleGapless1
|
? handleGapless1
|
||||||
: handleCrossfade1
|
: handleCrossfade1
|
||||||
}
|
}
|
||||||
@@ -170,14 +170,14 @@ export const AudioPlayer = forwardRef(
|
|||||||
ref={player2Ref}
|
ref={player2Ref}
|
||||||
height={0}
|
height={0}
|
||||||
muted={muted}
|
muted={muted}
|
||||||
playing={currentPlayer === 2 && status === PlayerStatus.Playing}
|
playing={currentPlayer === 2 && status === PlayerStatus.PLAYING}
|
||||||
progressInterval={isTransitioning ? 10 : 250}
|
progressInterval={isTransitioning ? 10 : 250}
|
||||||
url={player2?.streamUrl}
|
url={player2?.streamUrl}
|
||||||
volume={volume}
|
volume={volume}
|
||||||
width={0}
|
width={0}
|
||||||
onEnded={handleOnEnded}
|
onEnded={handleOnEnded}
|
||||||
onProgress={
|
onProgress={
|
||||||
playbackStyle === PlaybackStyle.Gapless
|
playbackStyle === PlaybackStyle.GAPLESS
|
||||||
? handleGapless2
|
? handleGapless2
|
||||||
: handleCrossfade2
|
: handleCrossfade2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useEffect, useMemo, useState } from 'react';
|
|||||||
import format from 'format-duration';
|
import format from 'format-duration';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import {
|
||||||
RiPauseFill,
|
RiPauseLine,
|
||||||
RiPlayFill,
|
RiPlayFill,
|
||||||
RiRewindFill,
|
RiRewindFill,
|
||||||
RiSkipBackFill,
|
RiSkipBackFill,
|
||||||
@@ -88,8 +88,8 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let interval: any;
|
let interval: any;
|
||||||
|
|
||||||
if (status === PlayerStatus.Playing && !isSeeking) {
|
if (status === PlayerStatus.PLAYING && !isSeeking) {
|
||||||
if (settings.type === PlaybackType.Web) {
|
if (settings.type === PlaybackType.WEB) {
|
||||||
interval = setInterval(() => {
|
interval = setInterval(() => {
|
||||||
setCurrentTime(currentPlayerRef.getCurrentTime());
|
setCurrentTime(currentPlayerRef.getCurrentTime());
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -119,15 +119,15 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
|
|||||||
/>
|
/>
|
||||||
<PlayerButton
|
<PlayerButton
|
||||||
icon={
|
icon={
|
||||||
status === PlayerStatus.Paused ? (
|
status === PlayerStatus.PAUSED ? (
|
||||||
<RiPlayFill size={20} />
|
<RiPlayFill size={20} />
|
||||||
) : (
|
) : (
|
||||||
<RiPauseFill size={20} />
|
<RiPauseLine size={20} stroke="20px" />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
tooltip={{
|
tooltip={{
|
||||||
label:
|
label:
|
||||||
status === PlayerStatus.Paused
|
status === PlayerStatus.PAUSED
|
||||||
? `${t('player.play')}`
|
? `${t('player.play')}`
|
||||||
: `${t('player.pause')}`,
|
: `${t('player.pause')}`,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const LeftControls = () => {
|
|||||||
to="/nowplaying"
|
to="/nowplaying"
|
||||||
weight={500}
|
weight={500}
|
||||||
>
|
>
|
||||||
{album || '—'}
|
{album?.name || '—'}
|
||||||
</Text>
|
</Text>
|
||||||
</MetadataStack>
|
</MetadataStack>
|
||||||
</LeftControlsContainer>
|
</LeftControlsContainer>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export const Playerbar = () => {
|
|||||||
<RightControls />
|
<RightControls />
|
||||||
</RightGridItem>
|
</RightGridItem>
|
||||||
</PlayerbarControlsGrid>
|
</PlayerbarControlsGrid>
|
||||||
{settings.type === PlaybackType.Web && (
|
{settings.type === PlaybackType.WEB && (
|
||||||
<AudioPlayer
|
<AudioPlayer
|
||||||
ref={playersRef}
|
ref={playersRef}
|
||||||
autoNext={autoNext}
|
autoNext={autoNext}
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ export type PlayerSettings = PlayerState['settings'];
|
|||||||
const DEFAULT_SETTINGS: WebSettings = {
|
const DEFAULT_SETTINGS: WebSettings = {
|
||||||
player: {
|
player: {
|
||||||
crossfadeDuration: 5,
|
crossfadeDuration: 5,
|
||||||
crossfadeStyle: CrossfadeStyle.EqualPower,
|
crossfadeStyle: CrossfadeStyle.EQUALPOWER,
|
||||||
muted: false,
|
muted: false,
|
||||||
repeat: PlayerRepeat.All,
|
repeat: PlayerRepeat.ALL,
|
||||||
shuffle: false,
|
shuffle: false,
|
||||||
style: PlaybackStyle.Gapless,
|
style: PlaybackStyle.GAPLESS,
|
||||||
type: isElectron() ? PlaybackType.Local : PlaybackType.Web,
|
type: isElectron() ? PlaybackType.LOCAL : PlaybackType.WEB,
|
||||||
volume: 0.5,
|
volume: 0.5,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export const usePlayerStore = create<PlayerSlice>()(
|
|||||||
index: 0,
|
index: 0,
|
||||||
player: 1,
|
player: 1,
|
||||||
song: {} as Song,
|
song: {} as Song,
|
||||||
status: PlayerStatus.Paused,
|
status: PlayerStatus.PAUSED,
|
||||||
time: 0,
|
time: 0,
|
||||||
},
|
},
|
||||||
getPlayerData: () => {
|
getPlayerData: () => {
|
||||||
@@ -171,14 +171,14 @@ export const usePlayerStore = create<PlayerSlice>()(
|
|||||||
pause: () => {
|
pause: () => {
|
||||||
set(
|
set(
|
||||||
produce((state) => {
|
produce((state) => {
|
||||||
state.current.status = PlayerStatus.Paused;
|
state.current.status = PlayerStatus.PAUSED;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
play: () => {
|
play: () => {
|
||||||
set(
|
set(
|
||||||
produce((state) => {
|
produce((state) => {
|
||||||
state.current.status = PlayerStatus.Playing;
|
state.current.status = PlayerStatus.PLAYING;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -228,12 +228,12 @@ export const usePlayerStore = create<PlayerSlice>()(
|
|||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
crossfadeDuration: 5,
|
crossfadeDuration: 5,
|
||||||
crossfadeStyle: CrossfadeStyle.EqualPower,
|
crossfadeStyle: CrossfadeStyle.EQUALPOWER,
|
||||||
muted: false,
|
muted: false,
|
||||||
repeat: PlayerRepeat.None,
|
repeat: PlayerRepeat.NONE,
|
||||||
shuffle: false,
|
shuffle: false,
|
||||||
style: PlaybackStyle.Gapless,
|
style: PlaybackStyle.GAPLESS,
|
||||||
type: PlaybackType.Local,
|
type: PlaybackType.LOCAL,
|
||||||
volume: 50,
|
volume: 50,
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-underscore-dangle */
|
/* eslint-disable no-underscore-dangle */
|
||||||
import meanBy from 'lodash/meanBy';
|
import meanBy from 'lodash/meanBy';
|
||||||
import { Rating, User } from '../types/types';
|
import { Item, Rating, User } from '../types/types';
|
||||||
import { getImageUrl } from '../utils';
|
import { getImageUrl } from '../utils';
|
||||||
|
|
||||||
const getSubsonicStreamUrl = (
|
const getSubsonicStreamUrl = (
|
||||||
@@ -71,12 +71,23 @@ const streamUrl = (
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const relatedAlbum = (item: any) => {
|
||||||
|
return {
|
||||||
|
deleted: item.deleted,
|
||||||
|
id: item.id,
|
||||||
|
itemType: Item.ALBUM,
|
||||||
|
name: item.name,
|
||||||
|
remoteId: item.remoteId,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const relatedArtists = (items: any[]) => {
|
const relatedArtists = (items: any[]) => {
|
||||||
return (
|
return (
|
||||||
items?.map((item: any) => {
|
items?.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
deleted: item.deleted,
|
deleted: item.deleted,
|
||||||
id: item.id,
|
id: item.id,
|
||||||
|
itemType: Item.ARTIST,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
remoteId: item.remoteId,
|
remoteId: item.remoteId,
|
||||||
};
|
};
|
||||||
@@ -84,11 +95,21 @@ const relatedArtists = (items: any[]) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const relatedAlbumArtist = (item: any) => {
|
||||||
|
return {
|
||||||
|
deleted: item.deleted,
|
||||||
|
id: item.id,
|
||||||
|
itemType: item.ALBUMARTIST,
|
||||||
|
name: item.name,
|
||||||
|
remoteId: item.remoteId,
|
||||||
|
};
|
||||||
|
};
|
||||||
const relatedGenres = (genres: any[]) => {
|
const relatedGenres = (genres: any[]) => {
|
||||||
return (
|
return (
|
||||||
genres?.map((genre) => {
|
genres?.map((genre) => {
|
||||||
return {
|
return {
|
||||||
id: genre.id,
|
id: genre.id,
|
||||||
|
itemType: Item.GENRE,
|
||||||
name: genre.name,
|
name: genre.name,
|
||||||
};
|
};
|
||||||
}) || []
|
}) || []
|
||||||
@@ -128,8 +149,7 @@ const songs = (
|
|||||||
const url = options.url ? options.url : item.server.serverUrls[0];
|
const url = options.url ? options.url : item.server.serverUrls[0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
album: item.album.name,
|
album: item.album && relatedAlbum(item.album),
|
||||||
albumId: item.albumId,
|
|
||||||
artistName: item.artistName,
|
artistName: item.artistName,
|
||||||
artists: relatedArtists(item.artists),
|
artists: relatedArtists(item.artists),
|
||||||
bitRate: item.bitRate,
|
bitRate: item.bitRate,
|
||||||
@@ -144,6 +164,7 @@ const songs = (
|
|||||||
imageUrl:
|
imageUrl:
|
||||||
primaryImage(item.images, serverType, url, item.remoteId) ||
|
primaryImage(item.images, serverType, url, item.remoteId) ||
|
||||||
options.imageUrl,
|
options.imageUrl,
|
||||||
|
itemType: Item.SONG,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
remoteCreatedAt: item.remoteCreatedAt,
|
remoteCreatedAt: item.remoteCreatedAt,
|
||||||
remoteId: item.remoteId,
|
remoteId: item.remoteId,
|
||||||
@@ -181,8 +202,7 @@ const albums = (items: any[], user: User) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
albumArtist: item.albumArtist,
|
albumArtist: item.albumArtist && relatedAlbumArtist(item.albumArtist),
|
||||||
albumArtistId: item.albumArtistId,
|
|
||||||
averageRating,
|
averageRating,
|
||||||
createdAt: item.createdAt,
|
createdAt: item.createdAt,
|
||||||
date: item.date,
|
date: item.date,
|
||||||
@@ -190,6 +210,7 @@ const albums = (items: any[], user: User) => {
|
|||||||
genres: relatedGenres(item.genres),
|
genres: relatedGenres(item.genres),
|
||||||
id: item.id,
|
id: item.id,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
|
itemType: Item.ALBUM,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
rating,
|
rating,
|
||||||
remoteCreatedAt: item.remoteCreatedAt,
|
remoteCreatedAt: item.remoteCreatedAt,
|
||||||
|
|||||||
@@ -3,6 +3,16 @@ export enum SortOrder {
|
|||||||
DESC = 'desc',
|
DESC = 'desc',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum Item {
|
||||||
|
ALBUM = 'album',
|
||||||
|
ALBUM_ARTIST = 'albumArtist',
|
||||||
|
ARTIST = 'artist',
|
||||||
|
FOLDER = 'folder',
|
||||||
|
GENRE = 'genre',
|
||||||
|
PLAYLIST = 'playlist',
|
||||||
|
SONG = 'song',
|
||||||
|
}
|
||||||
|
|
||||||
export enum AlbumFilter {
|
export enum AlbumFilter {
|
||||||
FAVORITED,
|
FAVORITED,
|
||||||
NOT_FAVORITED,
|
NOT_FAVORITED,
|
||||||
|
|||||||
+34
-61
@@ -1,17 +1,18 @@
|
|||||||
export enum Platform {
|
export enum Platform {
|
||||||
Linux = 'linux',
|
LINUX = 'linux',
|
||||||
MacOS = 'macos',
|
MACOS = 'macos',
|
||||||
Web = 'web',
|
WEB = 'web',
|
||||||
Windows = 'windows',
|
WINDOWS = 'windows',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ServerType {
|
export enum ServerType {
|
||||||
Jellyfin = 'jellyfin',
|
JELLYFIN = 'jellyfin',
|
||||||
Subsonic = 'subsonic',
|
SUBSONIC = 'subsonic',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Item {
|
export enum Item {
|
||||||
ALBUM = 'album',
|
ALBUM = 'album',
|
||||||
|
ALBUM_ARTIST = 'albumArtist',
|
||||||
ARTIST = 'artist',
|
ARTIST = 'artist',
|
||||||
FOLDER = 'folder',
|
FOLDER = 'folder',
|
||||||
GENRE = 'genre',
|
GENRE = 'genre',
|
||||||
@@ -20,14 +21,14 @@ export enum Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum PlayerStatus {
|
export enum PlayerStatus {
|
||||||
Paused = 'paused',
|
PAUSED = 'paused',
|
||||||
Playing = 'playing',
|
PLAYING = 'playing',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum PlayerRepeat {
|
export enum PlayerRepeat {
|
||||||
All = 'all',
|
ALL = 'all',
|
||||||
None = 'none',
|
NONE = 'none',
|
||||||
One = 'one',
|
ONE = 'one',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Play {
|
export enum Play {
|
||||||
@@ -37,22 +38,22 @@ export enum Play {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum CrossfadeStyle {
|
export enum CrossfadeStyle {
|
||||||
ConstantPower = 'constantPower',
|
CONSTANT_POWER = 'constantPower',
|
||||||
ConstantPowerSlowCut = 'constantPowerSlowCut',
|
CONSTANT_POWER_SLOW_CUT = 'constantPowerSlowCut',
|
||||||
ConstantPowerSlowFade = 'constantPowerSlowFade',
|
CONSTANT_POWER_SLOW_FADE = 'constantPowerSlowFade',
|
||||||
Dipped = 'dipped',
|
DIPPED = 'dipped',
|
||||||
EqualPower = 'equalPower',
|
EQUALPOWER = 'equalPower',
|
||||||
Linear = 'linear',
|
LINEAR = 'linear',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum PlaybackStyle {
|
export enum PlaybackStyle {
|
||||||
Crossfade = 'crossfade',
|
CROSSFADE = 'crossfade',
|
||||||
Gapless = 'gapless',
|
GAPLESS = 'gapless',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum PlaybackType {
|
export enum PlaybackType {
|
||||||
Local = 'local',
|
LOCAL = 'local',
|
||||||
Web = 'web',
|
WEB = 'web',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type APIEndpoints =
|
export type APIEndpoints =
|
||||||
@@ -97,25 +98,26 @@ export type APIEndpoints =
|
|||||||
| 'getSongsByGenre'
|
| 'getSongsByGenre'
|
||||||
| 'getLyrics';
|
| 'getLyrics';
|
||||||
|
|
||||||
export interface GenericItem {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface APIResult {
|
export interface APIResult {
|
||||||
data: Album[] | Artist[] | Genre[] | Song[];
|
data: Album[] | Artist[] | Genre[] | Song[];
|
||||||
totalRecordCount?: number;
|
totalRecordCount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface RelatedItem {
|
||||||
|
deleted?: boolean;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
remoteId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Album {
|
export interface Album {
|
||||||
albumArtist: Partial<AlbumArtist>;
|
albumArtist: AlbumArtist;
|
||||||
albumArtistId: string;
|
|
||||||
averageRating: number;
|
averageRating: number;
|
||||||
container: string;
|
container: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
date: string;
|
date: string;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
genres: Genre[];
|
genres: RelatedItem[];
|
||||||
id: number;
|
id: number;
|
||||||
imageUrl: string;
|
imageUrl: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -154,27 +156,15 @@ export interface Artist {
|
|||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ArtistInfo {
|
|
||||||
biography?: string;
|
|
||||||
externalUrl: GenericItem[];
|
|
||||||
imageUrl?: string;
|
|
||||||
similarArtist?: Artist[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Genre {
|
export interface Genre {
|
||||||
albumCount?: number;
|
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
songCount?: number;
|
|
||||||
type?: Item.GENRE;
|
|
||||||
uniqueId?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Song {
|
export interface Song {
|
||||||
album: string;
|
album: RelatedItem;
|
||||||
albumId: number;
|
|
||||||
artistName: null;
|
artistName: null;
|
||||||
artists: Partial<Artist>[];
|
artists: RelatedItem[];
|
||||||
bitRate: number;
|
bitRate: number;
|
||||||
container: string;
|
container: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
@@ -182,7 +172,7 @@ export interface Song {
|
|||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
disc: number;
|
disc: number;
|
||||||
duration: number;
|
duration: number;
|
||||||
genres: Partial<Genre>[];
|
genres: RelatedItem[];
|
||||||
id: number;
|
id: number;
|
||||||
imageUrl: string;
|
imageUrl: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -196,23 +186,6 @@ export interface Song {
|
|||||||
year: number;
|
year: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ScanStatus {
|
|
||||||
count: number | 'N/a';
|
|
||||||
scanning: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Sort {
|
|
||||||
column?: string;
|
|
||||||
type: 'asc' | 'desc';
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Pagination {
|
|
||||||
activePage?: number;
|
|
||||||
pages?: number;
|
|
||||||
recordsPerPage: number;
|
|
||||||
serverSide?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ServerFolderAuth {
|
export interface ServerFolderAuth {
|
||||||
id: number;
|
id: number;
|
||||||
locked: boolean;
|
locked: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user