import { cn } from '@/ui/lib/utils' import { m } from '@/ui/paraglide/messages.js' import { useUiStore } from '@/ui/stores/ui' import { Check, ChevronDown, Maximize, Minimize, Pause, Play, Repeat, Settings, Volume2, VolumeX, } from 'lucide-react' import React from 'react' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '../../ui/dropdown-menu' import ProgressBar from './progress-bar' import { formatTime, formatTimecode } from './utils' import type { ControlBarProps } from './video-control-bar' export const MobileVideoControlBar: React.FC = ({ state, isControlsVisible, buffered, data, resolutions, togglePlay, toggleLoop, toggleMute, changePlaybackRate, changeResolution, toggleFullScreen, frameRate, totalFrames, currentFrame, seekToFrame, floatOverlayInFullScreen = true, onMouseEnter, onMouseLeave, }) => { const { videoTimeDisplayMode, setVideoTimeDisplayMode } = useUiStore() if (!data.media?.metadata) { return null } const overlay = state.isFullScreen && floatOverlayInFullScreen const isAudio = data.proxyType === 'audio' const startTimecode = data.media?.metadata?.startTimecode const displayTotalFrames = Math.max(0, totalFrames - 1) const displayString = videoTimeDisplayMode === 'frames' ? `${currentFrame} / ${displayTotalFrames} fr` : videoTimeDisplayMode === 'standard' ? `${formatTimecode(currentFrame, frameRate, 'standard')} / ${formatTime(totalFrames / frameRate)}` : `${formatTimecode(currentFrame, frameRate, videoTimeDisplayMode, startTimecode)} / ${formatTimecode(displayTotalFrames, frameRate, videoTimeDisplayMode, startTimecode)}` return (
{/* Progress Bar */}
{/* Control Row */}
{/* Left Side: Play, Mute, Time */}
{displayString} {m.format()} setVideoTimeDisplayMode('standard')} className="flex items-center justify-between cursor-pointer text-xs" > {m.standard_time()} {videoTimeDisplayMode === 'standard' && ( )} setVideoTimeDisplayMode('frames')} className="flex items-center justify-between cursor-pointer text-xs" > {m.frames()} {videoTimeDisplayMode === 'frames' && ( )} setVideoTimeDisplayMode('timecode')} className="flex items-center justify-between cursor-pointer text-xs" > {m.timecode()} {videoTimeDisplayMode === 'timecode' && ( )}
{/* Right Side: Settings (Quality + Speed) & Fullscreen */}
{!isAudio && resolutions.length > 0 && ( <> {m.quality()} {resolutions.map((res) => ( changeResolution(res)} className={cn( 'flex w-full items-center justify-between text-xs cursor-pointer', state.currentResolution === res.resolution ? 'text-primary font-medium' : 'text-foreground', )} > {res.resolution === 'Original' ? m.original() : res.resolution} {res.width}x{res.height} ))} )} {m.playback_speed()} {[0.5, 1, 1.5, 2].map((rate) => ( changePlaybackRate(rate)} className={cn( 'flex items-center justify-between text-xs cursor-pointer', state.playbackRate === rate ? 'text-primary font-medium' : 'text-foreground', )} > {rate}x {state.playbackRate === rate && } ))} {m.loop()} {state.isLooping && } {/* Fullscreen */}
) }