14 changed files with 122 additions and 17 deletions
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
import { useCallback } from "react"; |
||||
|
||||
import { Icon, Icons } from "@/components/Icon"; |
||||
import { playerStatus } from "@/stores/player/slices/source"; |
||||
import { usePlayerStore } from "@/stores/player/store"; |
||||
|
||||
export function AutoPlayStart() { |
||||
const display = usePlayerStore((s) => s.display); |
||||
const isPlaying = usePlayerStore((s) => s.mediaPlaying.isPlaying); |
||||
const isLoading = usePlayerStore((s) => s.mediaPlaying.isLoading); |
||||
const hasPlayedOnce = usePlayerStore((s) => s.mediaPlaying.hasPlayedOnce); |
||||
const status = usePlayerStore((s) => s.status); |
||||
|
||||
const handleClick = useCallback(() => { |
||||
display?.play(); |
||||
}, [display]); |
||||
|
||||
if (hasPlayedOnce) return null; |
||||
if (isPlaying) return null; |
||||
if (isLoading) return null; |
||||
if (status !== playerStatus.PLAYING) return null; |
||||
|
||||
return ( |
||||
<div |
||||
onClick={handleClick} |
||||
className="group pointer-events-auto flex h-16 w-16 cursor-pointer items-center justify-center rounded-full bg-denim-400 text-white transition-[background-color,transform] hover:scale-125 hover:bg-denim-500 active:scale-100" |
||||
> |
||||
<Icon |
||||
icon={Icons.PLAY} |
||||
className="text-2xl transition-transform group-hover:scale-125" |
||||
/> |
||||
</div> |
||||
); |
||||
} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
import { Spinner } from "@/components/layout/Spinner"; |
||||
import { usePlayerStore } from "@/stores/player/store"; |
||||
|
||||
export function LoadingSpinner() { |
||||
const isLoading = usePlayerStore((s) => s.mediaPlaying.isLoading); |
||||
|
||||
if (!isLoading) return null; |
||||
|
||||
return <Spinner />; |
||||
} |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
export function CenterControls(props: { children: React.ReactNode }) { |
||||
return ( |
||||
<div className="absolute inset-0 flex items-center justify-center pointer-events-none [&>*]:pointer-events-auto"> |
||||
{props.children} |
||||
</div> |
||||
); |
||||
} |
Loading…
Reference in new issue