Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 3x 31x 31x 31x 1x 1x | // SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 Max Boksem. See NOTICE for additional terms under GPLv3 section 7.
import { Play, Pause } from "lucide-react";
import { cn } from "@/lib/utils";
import type { SkipIntervals } from "@/lib/player-prefs";
import { SkipIcon } from "./SkipIcon";
interface CenterControlsProps {
visible: boolean;
/** True while paused or stopped, so the middle button plays. */
paused: boolean;
onPlay: () => void;
onPause: () => void;
/** How far the skip buttons jump. Leave out when the stream can't seek. */
skip?: SkipIntervals;
onSkip?: (seconds: number) => void;
/** Leaves the buttons out, so the opening spinner or an error has the
* middle of the video to itself. */
hideButtons?: boolean;
}
/**
* The middle row of the touch player, with skip back, play or pause and skip
* forward. Only the buttons take taps, so a double-tap beside them still
* reaches the video. The skip buttons reach into the areas where a double-tap
* skips, which is harmless since they skip the same way. Anything else here,
* such as the episode buttons, would catch taps aimed at the video, so those stay
* in the bottom bar.
*/
export const CenterControls = ({
visible,
paused,
onPlay,
onPause,
skip,
onSkip,
hideButtons = false,
}: CenterControlsProps) => {
const skipButtons = skip && onSkip ? { skip, onSkip } : null;
const button = cn(
"flex shrink-0 items-center justify-center rounded-full text-white transition-transform active:scale-90",
visible && "pointer-events-auto"
);
return (
<div
className={cn(
"pointer-events-none absolute inset-0 flex items-center justify-center bg-black/30 transition-opacity duration-300",
visible ? "opacity-100" : "opacity-0"
)}
>
{!hideButtons && (
<div className="flex items-center gap-4 drop-shadow-[0_1px_3px_rgba(0,0,0,0.5)] sm:gap-8">
{skipButtons && (
<button
type="button"
onClick={() => skipButtons.onSkip(-skipButtons.skip.back)}
aria-label={`Skip back ${skipButtons.skip.back} seconds`}
className={cn(button, "h-14 w-14 active:bg-white/20")}
>
<SkipIcon
direction="back"
seconds={skipButtons.skip.back}
className="h-10 w-10"
labelClassName="text-xs"
/>
</button>
)}
<button
type="button"
onClick={paused ? onPlay : onPause}
aria-label={paused ? "Play" : "Pause"}
className={cn(
button,
"h-16 w-16 bg-black/40 active:bg-white/20 sm:h-20 sm:w-20"
)}
>
{paused ? (
<Play className="ml-1 h-8 w-8 fill-current sm:h-10 sm:w-10" />
) : (
<Pause className="h-8 w-8 fill-current sm:h-10 sm:w-10" />
)}
</button>
{skipButtons && (
<button
type="button"
onClick={() => skipButtons.onSkip(skipButtons.skip.forward)}
aria-label={`Skip forward ${skipButtons.skip.forward} seconds`}
className={cn(button, "h-14 w-14 active:bg-white/20")}
>
<SkipIcon
direction="forward"
seconds={skipButtons.skip.forward}
className="h-10 w-10"
labelClassName="text-xs"
/>
</button>
)}
</div>
)}
</div>
);
};
|