2025-02-15 15:22:07 -08:00
|
|
|
import React, { HTMLAttributes } from 'react';
|
|
|
|
|
import classNames from 'classnames';
|
2025-02-15 21:16:04 -08:00
|
|
|
import { FaPlay, FaPause, FaStepForward, FaStepBackward, FaVolumeUp } from 'react-icons/fa';
|
2025-02-15 15:22:07 -08:00
|
|
|
|
|
|
|
|
interface NowPlayingProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
|
|
songName: string;
|
|
|
|
|
fileName: string;
|
|
|
|
|
isPlaying: boolean;
|
2025-02-15 21:16:04 -08:00
|
|
|
volume: number;
|
2025-02-15 15:22:07 -08:00
|
|
|
onPlayPause: () => void;
|
2025-02-15 16:28:47 -08:00
|
|
|
onSkip: () => void;
|
|
|
|
|
onPrevious: () => void;
|
2025-02-15 21:16:04 -08:00
|
|
|
|
|
|
|
|
// Sent when the volume setting actually changes value
|
|
|
|
|
onVolumeSettingChange: (volume: number) => void;
|
|
|
|
|
|
|
|
|
|
// Sent when the volume is about to start changing
|
|
|
|
|
onVolumeWillChange: (volume: number) => void;
|
|
|
|
|
|
|
|
|
|
// Sent when the volume has changed
|
|
|
|
|
onVolumeDidChange: (volume: number) => void;
|
2025-02-15 15:22:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const NowPlaying: React.FC<NowPlayingProps> = (props) => {
|
|
|
|
|
return (
|
2025-02-15 16:28:47 -08:00
|
|
|
<div className={classNames(props.className, 'bg-black/50 h-[150px] p-5')}>
|
2025-02-15 15:22:07 -08:00
|
|
|
<div className="flex flex-col w-full gap-2">
|
|
|
|
|
<div className="flex flex-row w-full h-full bg-black/50 rounded-lg p-5 items-center">
|
2025-02-15 16:28:47 -08:00
|
|
|
<div className="flex-grow min-w-0">
|
|
|
|
|
<div className="text-white text-lg font-bold truncate">{props.songName}</div>
|
|
|
|
|
<div className="text-white text-sm truncate">{props.fileName}</div>
|
2025-02-15 15:22:07 -08:00
|
|
|
</div>
|
2025-02-15 21:16:04 -08:00
|
|
|
<div className="flex flex-row items-center gap-4">
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2 text-white">
|
|
|
|
|
<FaVolumeUp size={20} />
|
|
|
|
|
<input
|
|
|
|
|
type="range"
|
|
|
|
|
min="0"
|
|
|
|
|
max="100"
|
|
|
|
|
value={props.volume}
|
|
|
|
|
onMouseDown={() => props.onVolumeWillChange(props.volume)}
|
|
|
|
|
onMouseUp={() => props.onVolumeDidChange(props.volume)}
|
|
|
|
|
onChange={(e) => props.onVolumeSettingChange(Number(e.target.value))}
|
|
|
|
|
className="w-24 h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-violet-300"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-02-15 16:28:47 -08:00
|
|
|
<button className="text-white hover:text-violet-300 transition-colors" onClick={props.onPrevious}>
|
2025-02-15 15:22:07 -08:00
|
|
|
<FaStepBackward size={24} />
|
|
|
|
|
</button>
|
2025-02-15 21:16:04 -08:00
|
|
|
|
2025-02-15 15:22:07 -08:00
|
|
|
<button className="text-white hover:text-violet-300 transition-colors" onClick={props.onPlayPause}>
|
|
|
|
|
{props.isPlaying ? <FaPause size={24} /> : <FaPlay size={24} />}
|
|
|
|
|
</button>
|
2025-02-15 21:16:04 -08:00
|
|
|
|
2025-02-15 16:28:47 -08:00
|
|
|
<button className="text-white hover:text-violet-300 transition-colors" onClick={props.onSkip}>
|
2025-02-15 15:22:07 -08:00
|
|
|
<FaStepForward size={24} />
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default NowPlaying;
|