Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): dock player controls for timeline theater
Richie McIlroy166de5be6760
diff --git a/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx b/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsxindex efdf063dc..06064ec97 100644--- a/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx+++ b/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx@@ -7,9 +7,10 @@ import { faPlay } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { skipToken, useQuery, useQueryClient } from "@tanstack/react-query";import clsx from "clsx";-import { AnimatePresence, motion } from "framer-motion";import { AlertTriangleIcon, InfoIcon } from "lucide-react";+import { AnimatePresence, motion } from "motion/react";import { useCallback, useEffect, useRef, useState } from "react";+import { createPortal } from "react-dom";import { toast } from "sonner";import { retryVideoProcessing } from "@/actions/video/retry-processing";import CommentStamp from "./CommentStamp";@@ -58,6 +59,11 @@ import { captureVideoFrameDataUrl } from "./video-frame-thumbnail";const { circumference } = getProgressCircleConfig();+// Stable defaults: a `= []` in the destructuring mints a new array identity+// every render, which re-runs every hook/memo that lists the prop as a dep.+const NO_COMMENTS: NonNullable<Props["comments"]> = [];+const NO_CAPTIONS: CaptionOption[] = [];+function getProgressStatusText(status: "uploading" | "processing" | "generating_thumbnail",) {@@ -95,6 +101,14 @@ interface Props {disableReactionStamps?: boolean;disablePreviewGif?: boolean;disablePlaybackSpeedDial?: boolean;+ /** The share page's timeline deck owns scrubbing while visible. */+ externalTimeline?: boolean;+ /**+ * With `externalTimeline`, the deck row the control bar renders into via a+ * portal. Context crosses portals, so the bar keeps its player store; the+ * timeline strip replaces the seek slider, everything else comes along.+ */+ controlsPortalEl?: HTMLElement | null;comments?: Array<{id: string;timestamp: number | null;@@ -131,17 +145,19 @@ export function CapVideoPlayer({enableCrossOrigin = false,hasActiveUpload,blockPlaybackDuringProcessing = false,- comments = [],+ comments = NO_COMMENTS,disableCommentStamps = false,disableReactionStamps = false,disablePreviewGif = false,disablePlaybackSpeedDial = false,+ externalTimeline = false,+ controlsPortalEl = null,onSeek,enhancedAudioUrl: _enhancedAudioUrl,enhancedAudioStatus: _enhancedAudioStatus,captionLanguage,onCaptionLanguageChange,- availableCaptions = [],+ availableCaptions = NO_CAPTIONS,isCaptionLoading = false,hasCaptions = false,canRetryProcessing = false,@@ -452,10 +468,27 @@ export function CapVideoPlayer({videoRef.current,]);+ // The seek tooltip asks for a thumbnail on every render while the pointer is+ // over the bar (per animation frame). The capture snapshots the *displayed*+ // frame, so re-encoding is pure waste until the video has actually moved;+ // caching by currentTime (with a small tolerance while playing) bounds the+ // canvas + JPEG work to a few captures per second at most.+ const thumbnailCacheRef = useRef<{ time: number; url: string } | null>(null);const generateVideoFrameThumbnail = useCallback(- (_time: number): string | undefined =>- captureVideoFrameDataUrl({ video: videoRef.current }),- [videoRef.current],+ (_time: number): string | undefined => {+ const video = videoRef.current;+ if (!video) return undefined;+ const cached = thumbnailCacheRef.current;+ if (cached && Math.abs(cached.time - video.currentTime) < 0.25) {+ return cached.url;+ }+ const url = captureVideoFrameDataUrl({ video });+ if (url) {+ thumbnailCacheRef.current = { time: video.currentTime, url };+ }+ return url;+ },+ [videoRef],);const isUploadFailed = uploadProgress?.status === "failed";@@ -836,63 +869,92 @@ export function CapVideoPlayer({});})()}- <MediaPlayerControls- className={clsx(- "flex-col items-start gap-2.5",- showPlayButton && !hasPlayedOnce && "max-sm:hidden",- )}- mainControlsVisible={(arg: boolean) => setMainControlsVisible(arg)}- isUploadingOrFailed={blockPlaybackControls}- >- <MediaPlayerControlsOverlay className="rounded-b-xl" />- <MediaPlayerSeek- fallbackDuration={playerDuration}- tooltipThumbnailSrc={- isMobile || !resolvedSrc.data?.supportsCrossOrigin- ? undefined- : generateVideoFrameThumbnail- }- />- <div className="flex gap-2 items-center w-full">- <div className="flex flex-1 gap-2 items-center">- <MediaPlayerPlay />- <MediaPlayerSeekBackward className="hidden sm:inline-flex" />- <MediaPlayerSeekForward className="hidden sm:inline-flex" />- <MediaPlayerVolume- expandable- // enhancedAudioEnabled={enhancedAudioEnabled}- // enhancedAudioMuted={enhancedAudioMuted}- // setEnhancedAudioMuted={setEnhancedAudioMuted}- />- <MediaPlayerTime fallbackDuration={playerDuration} />- </div>- <div className="flex gap-2 items-center">- {!disableCaptions && (- <MediaPlayerCaptions- setToggleCaptions={setToggleCaptions}- toggleCaptions={toggleCaptions}+ {(() => {+ // Docked: the bar renders into the timeline deck's slot through a+ // portal. Same tree, same store; only where it paints changes. The+ // overrides pin it visible and static (twMerge drops the base+ // absolute/opacity-0/auto-hide classes).+ const docked = externalTimeline && controlsPortalEl !== null;+ const controls = (+ <MediaPlayerControls+ // Docked, the bar sits on the timeline card's white row instead+ // of on the video, so it drops its `dark` scope and the controls+ // resolve to dark-on-light off the same gray scale.+ tone={docked ? "light" : "dark"}+ className={clsx(+ docked+ ? "relative h-full flex-row items-center gap-2 opacity-100 pointer-events-auto"+ : "flex-col items-start gap-2.5",+ !docked && showPlayButton && !hasPlayedOnce && "max-sm:hidden",+ )}+ mainControlsVisible={(arg: boolean) => setMainControlsVisible(arg)}+ isUploadingOrFailed={blockPlaybackControls}+ >+ {!docked && <MediaPlayerControlsOverlay className="rounded-b-xl" />}+ {!externalTimeline && (+ <MediaPlayerSeek+ fallbackDuration={playerDuration}+ tooltipThumbnailSrc={+ isMobile || !resolvedSrc.data?.supportsCrossOrigin+ ? undefined+ : generateVideoFrameThumbnail+ }/>)}- {/* <MediaPlayerEnhancedAudio- enhancedAudioStatus={enhancedAudioStatus}- enhancedAudioEnabled={enhancedAudioEnabled}- setEnhancedAudioEnabled={setEnhancedAudioEnabled}- /> */}- <MediaPlayerSettings- // enhancedAudioStatus={enhancedAudioStatus}- // enhancedAudioEnabled={enhancedAudioEnabled}- // setEnhancedAudioEnabled={setEnhancedAudioEnabled}- captionLanguage={captionLanguage}- onCaptionLanguageChange={onCaptionLanguageChange}- availableCaptions={availableCaptions}- isCaptionLoading={isCaptionLoading}- hasCaptions={hasCaptions}- />- <MediaPlayerPiP />- <MediaPlayerFullscreen />- </div>- </div>- </MediaPlayerControls>+ <div className="flex gap-2 items-center w-full">+ <div className="flex flex-1 gap-2 items-center">+ <MediaPlayerPlay />+ <MediaPlayerSeekBackward className="hidden sm:inline-flex" />+ <MediaPlayerSeekForward className="hidden sm:inline-flex" />+ <MediaPlayerVolume+ expandable+ // Docked, the bar shares a phone-width row with the deck's+ // zoom cluster; volume and PiP are the two controls a phone+ // can live without (hardware rocker, and PiP is barely+ // supported in mobile browsers).+ className={docked ? "max-sm:hidden" : undefined}+ // enhancedAudioEnabled={enhancedAudioEnabled}+ // enhancedAudioMuted={enhancedAudioMuted}+ // setEnhancedAudioMuted={setEnhancedAudioMuted}+ />+ {(!externalTimeline || docked) && (+ <MediaPlayerTime fallbackDuration={playerDuration} />+ )}+ </div>+ <div className="flex gap-2 items-center">+ {!disableCaptions && (+ <MediaPlayerCaptions+ setToggleCaptions={setToggleCaptions}+ toggleCaptions={toggleCaptions}+ />+ )}+ {/* <MediaPlayerEnhancedAudio+ enhancedAudioStatus={enhancedAudioStatus}+ enhancedAudioEnabled={enhancedAudioEnabled}+ setEnhancedAudioEnabled={setEnhancedAudioEnabled}+ /> */}+ <MediaPlayerSettings+ // enhancedAudioStatus={enhancedAudioStatus}+ // enhancedAudioEnabled={enhancedAudioEnabled}+ // setEnhancedAudioEnabled={setEnhancedAudioEnabled}+ captionLanguage={captionLanguage}+ onCaptionLanguageChange={onCaptionLanguageChange}+ availableCaptions={availableCaptions}+ isCaptionLoading={isCaptionLoading}+ hasCaptions={hasCaptions}+ />+ <MediaPlayerPiP+ className={docked ? "max-sm:hidden" : undefined}+ />+ <MediaPlayerFullscreen />+ </div>+ </div>+ </MediaPlayerControls>+ );+ return docked && controlsPortalEl+ ? createPortal(controls, controlsPortalEl)+ : controls;+ })()}{/* {enhancedAudioUrl && (<><audiodiff --git a/apps/web/app/s/[videoId]/_components/CommentStamp.tsx b/apps/web/app/s/[videoId]/_components/CommentStamp.tsxindex 95011ccff..4d042a381 100644--- a/apps/web/app/s/[videoId]/_components/CommentStamp.tsx+++ b/apps/web/app/s/[videoId]/_components/CommentStamp.tsx@@ -30,6 +30,7 @@ const CommentStamp: React.FC<CommentStampsProps> = ({return (<divkey={comment.id}+ data-comment-stamp=""className="absolute z-[50]"style={{left: adjustedPosition,diff --git a/apps/web/app/s/[videoId]/_components/HLSVideoPlayer.tsx b/apps/web/app/s/[videoId]/_components/HLSVideoPlayer.tsxindex 825423317..a2fa9948c 100644--- a/apps/web/app/s/[videoId]/_components/HLSVideoPlayer.tsx+++ b/apps/web/app/s/[videoId]/_components/HLSVideoPlayer.tsx@@ -7,11 +7,12 @@ import { faPlay } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { useQueryClient } from "@tanstack/react-query";import clsx from "clsx";-import { AnimatePresence, motion } from "framer-motion";import Hls from "hls.js";import { AlertTriangleIcon } from "lucide-react";+import { AnimatePresence, motion } from "motion/react";import { useRouter } from "next/navigation";import { useCallback, useEffect, useRef, useState } from "react";+import { createPortal } from "react-dom";import { toast } from "sonner";import { retryVideoProcessing } from "@/actions/video/retry-processing";import { bindCaptionTrackCueText } from "./caption-tracks";@@ -51,6 +52,10 @@ const PROBE_MAX_RETRIES = 60;const PROBE_INITIAL_DELAY_MS = 1000;const PROBE_MAX_DELAY_MS = 8000;+// Stable default: `= []` in the destructuring would mint a new array identity+// every render and re-run everything that depends on the prop.+const NO_CAPTIONS: CaptionOption[] = [];+function getProgressStatusText(status: "uploading" | "processing" | "generating_thumbnail",) {@@ -104,6 +109,14 @@ interface Props {duration?: number | null;defaultPlaybackSpeed?: number;previewMode?: "background";+ /** The share page's timeline deck owns scrubbing while visible. */+ externalTimeline?: boolean;+ /**+ * With `externalTimeline`, the deck row the control bar renders into via a+ * portal. Context crosses portals, so the bar keeps its player store; the+ * timeline strip replaces the seek slider, everything else comes along.+ */+ controlsPortalEl?: HTMLElement | null;}export function HLSVideoPlayer({@@ -122,13 +135,15 @@ export function HLSVideoPlayer({enhancedAudioStatus: _enhancedAudioStatus,captionLanguage,onCaptionLanguageChange,- availableCaptions = [],+ availableCaptions = NO_CAPTIONS,isCaptionLoading = false,hasCaptions = false,canRetryProcessing = false,duration: fallbackDuration,defaultPlaybackSpeed,previewMode,+ externalTimeline = false,+ controlsPortalEl = null,}: Props) {const hlsInstance = useRef<Hls | null>(null);const [currentCue, setCurrentCue] = useState<string>("");@@ -408,7 +423,7 @@ export function HLSVideoPlayer({console.log(`HLSVideoPlayer: Fatal network error, retrying in ${delay}ms (attempt ${networkRetryCount}/${maxNetworkRetries})`,);- setTimeout(() => hls.startLoad(), delay);+ retryTimer = setTimeout(() => hls.startLoad(), delay);} else {console.log("HLSVideoPlayer: Network retries exhausted");setHlsInitFailed(true);@@ -525,6 +540,20 @@ export function HLSVideoPlayer({const prevUploadProgress =useRef<typeof uploadProgressRaw>(uploadProgressRaw);const pendingReadyRefreshRef = useRef(false);+ // The belt-and-braces second reload below must survive effect re-runs (its+ // whole point is firing after progress events settle), so it is only ever+ // cancelled on unmount.+ const delayedReloadTimerRef = useRef<ReturnType<typeof setTimeout> | null>(+ null,+ );+ useEffect(+ () => () => {+ if (delayedReloadTimerRef.current) {+ clearTimeout(delayedReloadTimerRef.current);+ }+ },+ [],+ );useEffect(() => {if (shouldReloadPlaybackAfterUploadCompletes(@@ -544,7 +573,10 @@ export function HLSVideoPlayer({if (!isLiveSegments || !videoLoadedRef.current) {reloadPlayback();- setTimeout(reloadPlayback, 1000);+ if (delayedReloadTimerRef.current) {+ clearTimeout(delayedReloadTimerRef.current);+ }+ delayedReloadTimerRef.current = setTimeout(reloadPlayback, 1000);}}prevUploadProgress.current = uploadProgressRaw;@@ -743,57 +775,86 @@ export function HLSVideoPlayer({<MediaPlayerLoading /><MediaPlayerError /><MediaPlayerVolumeIndicator />- <MediaPlayerControls- className={clsx(- "flex-col items-start gap-2.5",- showPlayButton && !hasPlayedOnce && "max-sm:hidden",- )}- isUploadingOrFailed={- isBackgroundPreview || hasActiveProgress || hasFailedOrError- }- >- <MediaPlayerControlsOverlay />- <MediaPlayerSeek fallbackDuration={playerDuration} />- <div className="flex gap-2 items-center w-full">- <div className="flex flex-1 gap-2 items-center">- <MediaPlayerPlay />- <MediaPlayerSeekBackward className="hidden sm:inline-flex" />- <MediaPlayerSeekForward className="hidden sm:inline-flex" />- <MediaPlayerVolume- expandable- // enhancedAudioEnabled={enhancedAudioEnabled}- // enhancedAudioMuted={enhancedAudioMuted}- // setEnhancedAudioMuted={setEnhancedAudioMuted}- />- <MediaPlayerTime fallbackDuration={playerDuration} />- </div>- <div className="flex gap-2 items-center">- {!disableCaptions && (- <MediaPlayerCaptions- setToggleCaptions={setToggleCaptions}- toggleCaptions={toggleCaptions}- />+ {(() => {+ // Docked: the bar renders into the timeline deck's slot through a+ // portal. Same tree, same store; only where it paints changes. The+ // overrides pin it visible and static (twMerge drops the base+ // absolute/opacity-0/auto-hide classes).+ const docked = externalTimeline && controlsPortalEl !== null;+ const controls = (+ <MediaPlayerControls+ // Docked, the bar sits on the timeline card's white row instead+ // of on the video, so it drops its `dark` scope and the controls+ // resolve to dark-on-light off the same gray scale.+ tone={docked ? "light" : "dark"}+ className={clsx(+ docked+ ? "relative h-full flex-row items-center gap-2 opacity-100 pointer-events-auto"+ : "flex-col items-start gap-2.5",+ !docked && showPlayButton && !hasPlayedOnce && "max-sm:hidden",)}- {/* <MediaPlayerEnhancedAudio- enhancedAudioStatus={enhancedAudioStatus}- enhancedAudioEnabled={enhancedAudioEnabled}- setEnhancedAudioEnabled={setEnhancedAudioEnabled}- /> */}- <MediaPlayerSettings- // enhancedAudioStatus={enhancedAudioStatus}- // enhancedAudioEnabled={enhancedAudioEnabled}- // setEnhancedAudioEnabled={setEnhancedAudioEnabled}- captionLanguage={captionLanguage}- onCaptionLanguageChange={onCaptionLanguageChange}- availableCaptions={availableCaptions}- isCaptionLoading={isCaptionLoading}- hasCaptions={hasCaptions}- />- <MediaPlayerPiP />- <MediaPlayerFullscreen />- </div>- </div>- </MediaPlayerControls>+ isUploadingOrFailed={+ isBackgroundPreview || hasActiveProgress || hasFailedOrError+ }+ >+ {!docked && <MediaPlayerControlsOverlay />}+ {!externalTimeline && (+ <MediaPlayerSeek fallbackDuration={playerDuration} />+ )}+ <div className="flex gap-2 items-center w-full">+ <div className="flex flex-1 gap-2 items-center">+ <MediaPlayerPlay />+ <MediaPlayerSeekBackward className="hidden sm:inline-flex" />+ <MediaPlayerSeekForward className="hidden sm:inline-flex" />+ <MediaPlayerVolume+ expandable+ // Docked, the bar shares a phone-width row with the deck's+ // zoom cluster; volume and PiP are the two controls a phone+ // can live without (hardware rocker, and PiP is barely+ // supported in mobile browsers).+ className={docked ? "max-sm:hidden" : undefined}+ // enhancedAudioEnabled={enhancedAudioEnabled}+ // enhancedAudioMuted={enhancedAudioMuted}+ // setEnhancedAudioMuted={setEnhancedAudioMuted}+ />+ {(!externalTimeline || docked) && (+ <MediaPlayerTime fallbackDuration={playerDuration} />+ )}+ </div>+ <div className="flex gap-2 items-center">+ {!disableCaptions && (+ <MediaPlayerCaptions+ setToggleCaptions={setToggleCaptions}+ toggleCaptions={toggleCaptions}+ />+ )}+ {/* <MediaPlayerEnhancedAudio+ enhancedAudioStatus={enhancedAudioStatus}+ enhancedAudioEnabled={enhancedAudioEnabled}+ setEnhancedAudioEnabled={setEnhancedAudioEnabled}+ /> */}+ <MediaPlayerSettings+ // enhancedAudioStatus={enhancedAudioStatus}+ // enhancedAudioEnabled={enhancedAudioEnabled}+ // setEnhancedAudioEnabled={setEnhancedAudioEnabled}+ captionLanguage={captionLanguage}+ onCaptionLanguageChange={onCaptionLanguageChange}+ availableCaptions={availableCaptions}+ isCaptionLoading={isCaptionLoading}+ hasCaptions={hasCaptions}+ />+ <MediaPlayerPiP+ className={docked ? "max-sm:hidden" : undefined}+ />+ <MediaPlayerFullscreen />+ </div>+ </div>+ </MediaPlayerControls>+ );+ return docked && controlsPortalEl+ ? createPortal(controls, controlsPortalEl)+ : controls;+ })()}{/* {enhancedAudioUrl && (<><audiodiff --git a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx b/apps/web/app/s/[videoId]/_components/ShareVideo.tsxindex 532081210..2ed72e014 100644--- a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx+++ b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx@@ -3,15 +3,18 @@ import { NODE_ENV } from "@cap/env";import { Logo } from "@cap/ui";import type { ImageUpload } from "@cap/web-domain";import * as TooltipPrimitive from "@radix-ui/react-tooltip";+import clsx from "clsx";import { useLiveTranscript } from "hooks/use-live-transcript";import { useTranscript } from "hooks/use-transcript";import { CheckCircle2, Info, Loader2Icon } from "lucide-react";+import dynamic from "next/dynamic";import { useRouter } from "next/navigation";import {forwardRef,useCallback,useEffect,useImperativeHandle,+ useMemo,useRef,useState,} from "react";@@ -21,9 +24,7 @@ import { UpgradeModal } from "@/components/UpgradeModal";import { isRetryableDesktopSegmentsFinalizationError } from "@/lib/desktop-segments-retryable-errors";import type { VideoData } from "../types";import { type CaptionLanguage, useCaptionContext } from "./CaptionContext";-import { CapVideoPlayer } from "./CapVideoPlayer";import { scheduleReadyRefresh } from "./deferred-ready-refresh";-import { HLSVideoPlayer } from "./HLSVideoPlayer";import {shouldDeferPlaybackSource,shouldReloadPlaybackAfterUploadCompletes,@@ -40,6 +41,18 @@ type CommentWithAuthor = typeof commentsSchema.$inferSelect & {authorImage: ImageUpload.ImageUrl | null;};+// Code-split the two players: a given share page only ever renders one of+// them (the source type is fixed per video), and the HLS player carries+// hls.js, which MP4 (instant) recordings never need. SSR still renders the+// taken branch and preloads its chunk, so the used player pays nothing; the+// unused player's chunk is simply never fetched.+const CapVideoPlayer = dynamic(() =>+ import("./CapVideoPlayer").then((m) => m.CapVideoPlayer),+);+const HLSVideoPlayer = dynamic(() =>+ import("./HLSVideoPlayer").then((m) => m.HLSVideoPlayer),+);+type AiGenerationStatus =| "QUEUED"| "PROCESSING"@@ -47,6 +60,10 @@ type AiGenerationStatus =| "ERROR"| "SKIPPED";+// Stable default: `= []` in the destructuring would mint a new array identity+// every render and re-run the chapters VTT effect below each time.+const NO_CHAPTERS: { title: string; start: number }[] = [];+export const ShareVideo = forwardRef<HTMLVideoElement,{@@ -59,6 +76,10 @@ export const ShareVideo = forwardRef<areCaptionsDisabled?: boolean;areCommentStampsDisabled?: boolean;areReactionStampsDisabled?: boolean;+ /** Timeline view scrubs on the deck below the video, not in it. */+ externalTimeline?: boolean;+ /** Deck row the player's control bar renders into while the timeline is up. */+ controlsPortalEl?: HTMLElement | null;aiGenerationStatus?: AiGenerationStatus | null;canRetryProcessing?: boolean;canFinalizeDesktopSegments?: boolean;@@ -72,11 +93,13 @@ export const ShareVideo = forwardRef<{data,comments,- chapters = [],+ chapters = NO_CHAPTERS,areCaptionsDisabled,areChaptersDisabled,areCommentStampsDisabled,areReactionStampsDisabled,+ externalTimeline = false,+ controlsPortalEl = null,canRetryProcessing,canFinalizeDesktopSegments = false,showPlaybackStatusBadge = false,@@ -147,6 +170,28 @@ export const ShareVideo = forwardRef<}}, [comments]);+ // Media comments live on the timeline view, not as over-player stamps.+ // Memoised so the player's comment markers keep a stable identity across+ // the frequent re-renders this component sees during playback.+ const stampComments = useMemo(+ () =>+ commentsData.flatMap((comment) =>+ comment.type === "text" || comment.type === "emoji"+ ? [+ {+ id: comment.id,+ type: comment.type,+ timestamp: comment.timestamp,+ content: comment.content,+ authorName: comment.authorName,+ authorImage: comment.authorImage ?? undefined,+ },+ ]+ : [],+ ),+ [commentsData],+ );+useEffect(() => {if (recordingStopped) {setUserConfirmedStopped(true);@@ -470,7 +515,12 @@ export const ShareVideo = forwardRef<) : isMp4Source ? (<CapVideoPlayervideoId={data.id}- mediaPlayerClassName="w-full h-full max-w-full max-h-full rounded-xl overflow-visible"+ mediaPlayerClassName={clsx(+ "w-full h-full max-w-full max-h-full overflow-visible",+ // Timeline view: the player is a slice of the widescreen+ // theater block, so no rounded corners against the black.+ externalTimeline ? "rounded-none" : "rounded-xl",+ )}videoSrc={videoSrc}rawFallbackSrc={rawFallbackSrc}duration={data.duration}@@ -479,6 +529,8 @@ export const ShareVideo = forwardRef<disableCaptions={areCaptionsDisabled ?? false}disableCommentStamps={areCommentStampsDisabled ?? false}disableReactionStamps={areReactionStampsDisabled ?? false}+ externalTimeline={externalTimeline}+ controlsPortalEl={controlsPortalEl}chaptersSrc={areChaptersDisabled ? "" : chaptersUrl || ""}captionsSrc={areCaptionsDisabled ? "" : subtitleUrl || ""}videoRef={videoRef}@@ -486,14 +538,7 @@ export const ShareVideo = forwardRef<hasActiveUpload={data.hasActiveUpload}blockPlaybackDuringProcessing={isEditProcessing}onUploadComplete={handleUploadComplete}- comments={commentsData.map((comment) => ({- id: comment.id,- type: comment.type,- timestamp: comment.timestamp,- content: comment.content,- authorName: comment.authorName,- authorImage: comment.authorImage ?? undefined,- }))}+ comments={stampComments}onSeek={handleSeek}captionLanguage={captionContext.selectedLanguage}onCaptionLanguageChange={handleCaptionLanguageChange}@@ -508,10 +553,15 @@ export const ShareVideo = forwardRef<) : (<HLSVideoPlayervideoId={data.id}- mediaPlayerClassName="w-full h-full max-w-full max-h-full rounded-xl"+ mediaPlayerClassName={clsx(+ "w-full h-full max-w-full max-h-full",+ externalTimeline ? "rounded-none" : "rounded-xl",+ )}videoSrc={videoSrc}duration={data.duration}defaultPlaybackSpeed={defaultPlaybackSpeed}+ externalTimeline={externalTimeline}+ controlsPortalEl={controlsPortalEl}disableCaptions={areCaptionsDisabled ?? false}chaptersSrc={areChaptersDisabled ? "" : chaptersUrl || ""}captionsSrc={areCaptionsDisabled ? "" : subtitleUrl || ""}diff --git a/apps/web/app/s/[videoId]/_components/video/button.tsx b/apps/web/app/s/[videoId]/_components/video/button.tsxindex c354b134c..f7bb8c501 100644--- a/apps/web/app/s/[videoId]/_components/video/button.tsx+++ b/apps/web/app/s/[videoId]/_components/video/button.tsx@@ -17,7 +17,10 @@ const buttonVariants = cva("border border-input bg-background shadow-sm hover:bg-white/50 hover:text-white",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",- ghost: "hover:bg-white/20 hover:text-white",+ // Gray-scale rather than literal white: the controls scope themselves+ // `dark` over video (where gray-12 is near-white) but drop it when the+ // bar is docked into the timeline card's light row.+ ghost: "hover:bg-gray-12/15 hover:text-gray-12",link: "text-primary underline-offset-4 hover:underline",},size: {diff --git a/apps/web/app/s/[videoId]/_components/video/media-player.tsx b/apps/web/app/s/[videoId]/_components/video/media-player.tsxindex ba5d33ed2..cac9de63c 100644--- a/apps/web/app/s/[videoId]/_components/video/media-player.tsx+++ b/apps/web/app/s/[videoId]/_components/video/media-player.tsx@@ -13,7 +13,6 @@ import {} from "@cap/ui";import * as SliderPrimitive from "@radix-ui/react-slider";import { Slot } from "@radix-ui/react-slot";-import { AnimatePresence, motion } from "framer-motion";import {AlertTriangleIcon,CaptionsOffIcon,@@ -51,6 +50,7 @@ import {useMediaFullscreenRef,useMediaRef,} from "media-chrome/react/media-store";+import { AnimatePresence, motion } from "motion/react";import * as React from "react";import { forwardRef, useEffect } from "react";import * as ReactDOM from "react-dom";@@ -384,7 +384,6 @@ function MediaPlayerRootImpl(props: MediaPlayerRootProps) {const menuOpen = useStoreSelector((state) => state.menuOpen);const hideControlsTimeoutRef = React.useRef<NodeJS.Timeout | null>(null);- const lastMouseMoveRef = React.useRef<number>(Date.now());const volumeIndicatorTimeoutRef = React.useRef<NodeJS.Timeout | null>(null);const mediaPaused = useMediaSelector(selectPaused);@@ -406,7 +405,6 @@ function MediaPlayerRootImpl(props: MediaPlayerRootProps) {const onControlsShow = React.useCallback(() => {store.setState("controlsVisible", true);- lastMouseMoveRef.current = Date.now();if (hideControlsTimeoutRef.current) {clearTimeout(hideControlsTimeoutRef.current);@@ -764,26 +762,25 @@ function MediaPlayerRootImpl(props: MediaPlayerRootProps) {const mediaElement = mediaRef.current;if (!mediaElement) return;+ const handleTimeUpdate = () => onTimeUpdate?.(mediaElement.currentTime);+ const handleVolumeChange = () => {+ onVolumeChange?.(mediaElement.volume);+ onMuted?.(mediaElement.muted);+ };+ const handleError = () => onMediaError?.(mediaElement.error);+ const handleFullscreenChange = () =>+ onFullscreenChange?.(!!document.fullscreenElement);+if (onPlay) mediaElement.addEventListener("play", onPlay);if (onPause) mediaElement.addEventListener("pause", onPause);if (onEnded) mediaElement.addEventListener("ended", onEnded);if (onTimeUpdate)- mediaElement.addEventListener("timeupdate", () =>- onTimeUpdate?.(mediaElement.currentTime),- );+ mediaElement.addEventListener("timeupdate", handleTimeUpdate);if (onVolumeChange)- mediaElement.addEventListener("volumechange", () => {- onVolumeChange?.(mediaElement.volume);- onMuted?.(mediaElement.muted);- });- if (onMediaError)- mediaElement.addEventListener("error", () =>- onMediaError?.(mediaElement.error),- );+ mediaElement.addEventListener("volumechange", handleVolumeChange);+ if (onMediaError) mediaElement.addEventListener("error", handleError);if (onFullscreenChange) {- document.addEventListener("fullscreenchange", () =>- onFullscreenChange?.(!!document.fullscreenElement),- );+ document.addEventListener("fullscreenchange", handleFullscreenChange);}return () => {@@ -791,21 +788,14 @@ function MediaPlayerRootImpl(props: MediaPlayerRootProps) {if (onPause) mediaElement.removeEventListener("pause", onPause);if (onEnded) mediaElement.removeEventListener("ended", onEnded);if (onTimeUpdate)- mediaElement.removeEventListener("timeupdate", () =>- onTimeUpdate?.(mediaElement.currentTime),- );+ mediaElement.removeEventListener("timeupdate", handleTimeUpdate);if (onVolumeChange)- mediaElement.removeEventListener("volumechange", () => {- onVolumeChange?.(mediaElement.volume);- onMuted?.(mediaElement.muted);- });- if (onMediaError)- mediaElement.removeEventListener("error", () =>- onMediaError?.(mediaElement.error),- );+ mediaElement.removeEventListener("volumechange", handleVolumeChange);+ if (onMediaError) mediaElement.removeEventListener("error", handleError);if (onFullscreenChange) {- document.removeEventListener("fullscreenchange", () =>- onFullscreenChange?.(!!document.fullscreenElement),+ document.removeEventListener(+ "fullscreenchange",+ handleFullscreenChange,);}if (volumeIndicatorTimeoutRef.current) {@@ -878,7 +868,13 @@ function MediaPlayerRootImpl(props: MediaPlayerRootProps) {onKeyUp={onKeyUp}className={cn("dark relative isolate flex flex-col overflow-visible bg-background outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_video]:relative [&_video]:object-contain",- "data-[state=fullscreen]:[&_video]:size-full [:fullscreen_&]:flex [:fullscreen_&]:h-full [:fullscreen_&]:max-h-screen [:fullscreen_&]:flex-col [:fullscreen_&]:justify-between",+ // The root never clips (overlays must escape), so a video whose+ // aspect exactly fills the box would paint square corners over+ // the root's radius. Inheriting keeps the video's corners in+ // lockstep with whatever radius the instance sets — including+ // rounded-none in the timeline's theater strip.+ "[&_video]:rounded-[inherit]",+ "data-[state=fullscreen]:[&_video]:size-full data-[state=fullscreen]:[&_video]:rounded-none [:fullscreen_&]:flex [:fullscreen_&]:h-full [:fullscreen_&]:max-h-screen [:fullscreen_&]:flex-col [:fullscreen_&]:justify-between","[&_[data-slider]::before]:-top-4 [&_[data-slider]::before]:-bottom-2 [&_[data-slider]::before]:absolute [&_[data-slider]::before]:inset-x-0 [&_[data-slider]::before]:z-10 [&_[data-slider]::before]:h-8 [&_[data-slider]::before]:cursor-pointer [&_[data-slider]::before]:content-[''] [&_[data-slider]]:relative [&_[data-slot='media-player-seek']:not([data-hovering])::before]:cursor-default","[&_video::-webkit-media-text-track-display]:top-auto! [&_video::-webkit-media-text-track-display]:bottom-[4%]! [&_video::-webkit-media-text-track-display]:mb-0! data-[state=fullscreen]:data-[controls-visible]:[&_video::-webkit-media-text-track-display]:bottom-[9%]! data-[controls-visible]:[&_video::-webkit-media-text-track-display]:bottom-[13%]! data-[state=fullscreen]:[&_video::-webkit-media-text-track-display]:bottom-[7%]!",className,@@ -989,6 +985,13 @@ interface MediaPlayerControlsProps extends React.ComponentProps<"div"> {asChild?: boolean;isUploadingOrFailed?: boolean;mainControlsVisible?: (arg: boolean) => void;+ /**+ * The bar normally sits on top of video, so it scopes itself `dark` and its+ * pieces resolve to near-white off the gray scale. "light" drops that scope+ * for the one place the bar leaves the video: docked into the timeline+ * card's white control row.+ */+ tone?: "dark" | "light";}function MediaPlayerControls(props: MediaPlayerControlsProps) {@@ -997,6 +1000,7 @@ function MediaPlayerControls(props: MediaPlayerControlsProps) {className,isUploadingOrFailed,mainControlsVisible,+ tone = "dark",...controlsProps} = props;@@ -1017,12 +1021,14 @@ function MediaPlayerControls(props: MediaPlayerControlsProps) {return (<ControlsPrimitivedata-disabled={context.disabled ? "" : undefined}+ data-media-player-controls=""data-slot="media-player-controls"data-state={isFullscreen ? "fullscreen" : "windowed"}data-visible={controlsVisible ? "" : undefined}dir={context.dir}className={cn(- "dark pointer-events-none absolute right-0 bottom-0 left-0 z-50 flex items-center gap-2 px-4 py-3 opacity-0 transition-opacity duration-200 data-[visible]:pointer-events-auto data-[visible]:opacity-100 [:fullscreen_&]:px-6 [:fullscreen_&]:py-4",+ tone === "dark" && "dark",+ "pointer-events-none absolute right-0 bottom-0 left-0 z-50 flex items-center gap-2 px-4 py-3 opacity-0 transition-opacity duration-200 data-[visible]:pointer-events-auto data-[visible]:opacity-100 [:fullscreen_&]:px-6 [:fullscreen_&]:py-4",className,)}{...controlsProps}@@ -2498,10 +2504,12 @@ function MediaPlayerVolume(props: MediaPlayerVolumeProps) {onValueChange={onVolumeChange}onValueCommit={onVolumeCommit}>- <SliderPrimitive.Track className="overflow-hidden relative w-full h-1 rounded-full grow bg-zinc-500">- <SliderPrimitive.Range className="absolute h-full bg-white will-change-[width]" />+ {/* Gray-scale rather than literal white/zinc so the slider follows+ whatever tone the controls are scoped to. */}+ <SliderPrimitive.Track className="overflow-hidden relative w-full h-1 rounded-full grow bg-gray-8">+ <SliderPrimitive.Range className="absolute h-full bg-gray-12 will-change-[width]" /></SliderPrimitive.Track>- <SliderPrimitive.Thumb className="block size-2.5 shrink-0 rounded-full bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] will-change-transform hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50" />+ <SliderPrimitive.Thumb className="block size-2.5 shrink-0 rounded-full bg-gray-12 shadow-sm ring-ring/50 transition-[color,box-shadow] will-change-transform hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50" /></SliderPrimitive.Root></div>);@@ -2581,7 +2589,7 @@ function MediaPlayerTime(props: MediaPlayerTimeProps) {data-variant={variant}dir={context.dir}{...timeProps}- className={cn("text-sm tabular-nums text-white", className)}+ className={cn("text-sm tabular-nums text-gray-12", className)}>{times[variant]}</TimePrimitive>@@ -2595,17 +2603,17 @@ function MediaPlayerTime(props: MediaPlayerTimeProps) {dir={context.dir}{...timeProps}className={cn(- "flex gap-1 items-center text-sm text-white min-w-fit",+ "flex gap-1 items-center text-sm text-gray-12 min-w-fit",className,)}>- <span className="text-xs tabular-nums text-white min-w-fit md:text-base">+ <span className="text-xs tabular-nums text-gray-12 min-w-fit md:text-base">{times.current}</span><span className="text-xs tabular-nums text-gray-11" aria-hidden="true">/</span>- <span className="text-xs tabular-nums text-white min-w-fit md:text-base">+ <span className="text-xs tabular-nums text-gray-12 min-w-fit md:text-base">{times.duration}</span></TimePrimitive>@@ -3555,7 +3563,10 @@ function MediaPlayerSettings(props: MediaPlayerSettingsProps) {{...settingsProps}variant="ghost"size="icon"- className={cn("size-8 aria-[expanded=true]:bg-white/50", className)}+ className={cn(+ "size-8 aria-[expanded=true]:bg-gray-12/20",+ className,+ )}><SettingsIcon /></PlayerButton>