mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-21 22:15:40 +00:00
7a7a9f5e6b
111 of 122 top-level src/utils/ files move into 16 topic folders (audio, cache, cover, share, server, playback, playlist, deviceSync, waveform, mix, format, export, changelog, ui, perf, componentHelpers). True singletons with no cluster stay at the utils/ root. Pure file-move: a path-aware codemod rewrote 539 relative-import specifiers across 275 files; no logic touched. The hot-path coverage gate list (.github/frontend-hot-path-files.txt) is updated to the new paths for the 11 gated utils files — a mechanical consequence of the move, not a CI change. tsc is green.
76 lines
2.9 KiB
TypeScript
76 lines
2.9 KiB
TypeScript
import { ArrowLeftRight } from 'lucide-react';
|
|
import type { TFunction } from 'i18next';
|
|
import type { RadioMetadata } from '../../hooks/useRadioMetadata';
|
|
import { useThemeStore } from '../../store/themeStore';
|
|
import { formatTime } from '../../utils/componentHelpers/playerBarHelpers';
|
|
import WaveformSeek from '../WaveformSeek';
|
|
import { PlaybackTime, RemainingTime } from './PlaybackClock';
|
|
|
|
interface Props {
|
|
isRadio: boolean;
|
|
radioMeta: RadioMetadata;
|
|
trackId: string | undefined;
|
|
duration: number;
|
|
localShowRemaining: boolean;
|
|
setLocalShowRemaining: (v: boolean) => void;
|
|
disableWaveformCanvas: boolean;
|
|
t: TFunction;
|
|
}
|
|
|
|
export function PlayerSeekbarSection({
|
|
isRadio, radioMeta, trackId, duration, localShowRemaining, setLocalShowRemaining,
|
|
disableWaveformCanvas, t,
|
|
}: Props) {
|
|
return (
|
|
<div className="player-waveform-section">
|
|
{isRadio ? (
|
|
<>
|
|
{radioMeta.source === 'azuracast' && radioMeta.elapsed != null && radioMeta.duration != null && radioMeta.duration > 0 ? (
|
|
<>
|
|
<span className="player-time">{formatTime(radioMeta.elapsed)}</span>
|
|
<div className="player-waveform-wrap">
|
|
<div className="radio-progress-bar">
|
|
<div
|
|
className="radio-progress-fill"
|
|
style={{ width: `${Math.min(100, (radioMeta.elapsed / radioMeta.duration) * 100)}%` }}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<span className="player-time">{formatTime(radioMeta.duration)}</span>
|
|
</>
|
|
) : (
|
|
<>
|
|
<PlaybackTime className="player-time" />
|
|
<div className="player-waveform-wrap" style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
<span className="radio-live-badge">{t('radio.live')}</span>
|
|
</div>
|
|
<span className="player-time" style={{ opacity: 0 }}>0:00</span>
|
|
</>
|
|
)}
|
|
</>
|
|
) : (
|
|
<>
|
|
<PlaybackTime className="player-time" />
|
|
<div className="player-waveform-wrap">
|
|
{disableWaveformCanvas
|
|
? <div className="radio-progress-bar" aria-hidden />
|
|
: <WaveformSeek trackId={trackId} />}
|
|
</div>
|
|
<span
|
|
className="player-time player-time-toggle"
|
|
onClick={() => {
|
|
const newVal = !localShowRemaining;
|
|
setLocalShowRemaining(newVal);
|
|
useThemeStore.getState().setShowRemainingTime(newVal);
|
|
}}
|
|
data-tooltip={localShowRemaining ? t('player.showDuration') : t('player.showRemainingTime')}
|
|
>
|
|
{localShowRemaining ? <RemainingTime duration={duration} /> : formatTime(duration)}
|
|
<ArrowLeftRight size={10} style={{ marginLeft: 4, opacity: 0.6 }} />
|
|
</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|