Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore: no thumbnail scrubbing on mobile (#781)

Ameer Al Ashhabec1d2b99c939
diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsx
index 3a75c410f..83e1d8cae 100644
--- a/apps/web/app/s/[videoId]/Share.tsx
+++ b/apps/web/app/s/[videoId]/Share.tsx
@@ -206,15 +206,19 @@ export const Share = ({
<div className="mt-4">
<div className="flex flex-col gap-4 lg:flex-row">
<div className="flex-1">
- <div className="relative p-3 aspect-video new-card-style">
- <ShareVideo
- data={{ ...data, transcriptionStatus }}
- user={user}
- comments={comments}
- chapters={aiData?.chapters || []}
- aiProcessing={aiData?.processing || false}
- ref={playerRef}
- />
+ <div className="overflow-hidden relative p-3 aspect-video new-card-style">
+ <div
+ className="absolute inset-3 w-[calc(100%-1.5rem)] h-[calc(100%-1.5rem)] overflow-hidden rounded-xl"
+ >
+ <ShareVideo
+ data={{ ...data, transcriptionStatus }}
+ user={user}
+ comments={comments}
+ chapters={aiData?.chapters || []}
+ aiProcessing={aiData?.processing || false}
+ ref={playerRef}
+ />
+ </div>
</div>
<div className="mt-4 lg:hidden">
<Toolbar data={data} user={user} />
diff --git a/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx b/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx
index ac6dbacb4..893f73779 100644
--- a/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx
+++ b/apps/web/app/s/[videoId]/_components/CapVideoPlayer.tsx
@@ -53,14 +53,24 @@ export function CapVideoPlayer({
const [showPlayButton, setShowPlayButton] = useState(false);
const [videoLoaded, setVideoLoaded] = useState(false);
const [hasPlayedOnce, setHasPlayedOnce] = useState(false);
+ const [isMobile, setIsMobile] = useState(false);
+
+ useEffect(() => {
+ const checkMobile = () => {
+ setIsMobile(window.innerWidth < 640);
+ };
+
+ checkMobile();
+ window.addEventListener('resize', checkMobile);
+
+ return () => window.removeEventListener('resize', checkMobile);
+ }, []);
- // Set up video event listeners for better loading detection
useEffect(() => {
const video = videoRef.current;
if (!video) return;
const handleLoadedData = () => {
- console.log('Video loadeddata event fired');
setVideoLoaded(true);
if (!hasPlayedOnce) {
setShowPlayButton(true);
@@ -102,7 +112,6 @@ export function CapVideoPlayer({
video.addEventListener('play', handlePlay);
if (video.readyState >= 2) {
- console.log('Video already loaded, readyState:', video.readyState);
setVideoLoaded(true);
if (!hasPlayedOnce) {
setShowPlayButton(true);
@@ -124,13 +133,11 @@ export function CapVideoPlayer({
const videoElement = videoRef.current;
if (!Hls.isSupported()) {
- console.warn("HLS is not supported in this browser");
return;
}
const isHlsStream = videoSrc.includes('.m3u8');
if (!isHlsStream) {
- console.warn("Video source doesn't appear to be an HLS stream");
return;
}
@@ -148,20 +155,15 @@ export function CapVideoPlayer({
const wasPaused = videoElement.paused;
hls.on(Hls.Events.ERROR, (event, data) => {
- console.error("HLS error:", data);
-
if (data.fatal) {
switch (data.type) {
case Hls.ErrorTypes.NETWORK_ERROR:
- console.log("Network error, trying to recover...");
hls.startLoad();
break;
case Hls.ErrorTypes.MEDIA_ERROR:
- console.log("Media error, trying to recover...");
hls.recoverMediaError();
break;
default:
- console.error("Fatal error, destroying HLS instance");
hls.destroy();
break;
}
@@ -169,8 +171,6 @@ export function CapVideoPlayer({
});
hls.on(Hls.Events.MANIFEST_PARSED, () => {
- console.log("HLS manifest parsed successfully");
-
if (currentTime > 0) {
videoElement.currentTime = currentTime;
}
@@ -182,10 +182,7 @@ export function CapVideoPlayer({
}
});
- // HLS specific events for better loading detection
hls.on(Hls.Events.FRAG_LOADED, () => {
- console.log("HLS fragment loaded");
- // Set video as loaded when first fragment is loaded
if (!videoLoaded) {
setVideoLoaded(true);
if (!hasPlayedOnce) {
@@ -223,7 +220,6 @@ export function CapVideoPlayer({
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
return canvas.toDataURL('image/jpeg', 0.8);
} catch (error) {
- console.error('Error capturing video frame:', error);
return `https://placeholder.pics/svg/224x128/dc2626/ffffff/Error`;
}
}
@@ -277,7 +273,6 @@ export function CapVideoPlayer({
};
}, []);
-
return (
<>
<MediaPlayer
@@ -346,7 +341,7 @@ export function CapVideoPlayer({
<MediaPlayerVolumeIndicator />
<MediaPlayerControls className="flex-col items-start gap-2.5">
<MediaPlayerControlsOverlay />
- <MediaPlayerSeek tooltipThumbnailSrc={generateVideoFrameThumbnail} />
+ <MediaPlayerSeek tooltipThumbnailSrc={isMobile ? undefined : generateVideoFrameThumbnail} />
<div className="flex gap-2 items-center w-full">
<div className="flex flex-1 gap-2 items-center">
<MediaPlayerPlay />
diff --git a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
index aa0b4a51a..f0475f419 100644
--- a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
@@ -134,7 +134,7 @@ export const ShareVideo = forwardRef<
<>
<div className="relative h-full">
- <CapVideoPlayer hlsVideo={videoType === "application/x-mpegURL"} mediaPlayerClassName="w-full rounded-xl h-full"
+ <CapVideoPlayer hlsVideo={videoType === "application/x-mpegURL"} mediaPlayerClassName="w-full h-full max-w-full max-h-full rounded-xl"
videoSrc={videoSrc} chaptersSrc={chaptersUrl || ""} captionsSrc={subtitleUrl || ""} videoRef={videoRef} />
</div>
diff --git a/apps/web/app/s/[videoId]/_components/video/media-player.tsx b/apps/web/app/s/[videoId]/_components/video/media-player.tsx
index 3dc9a4a63..5b7413ddd 100644
--- a/apps/web/app/s/[videoId]/_components/video/media-player.tsx
+++ b/apps/web/app/s/[videoId]/_components/video/media-player.tsx
@@ -523,14 +523,14 @@ function MediaPlayerRootImpl(props: MediaPlayerRootProps) {
break;
}
- case "c":
- event.preventDefault();
- if (isVideo && mediaElement.textTracks.length > 0) {
- dispatch({
- type: MediaActionTypes.MEDIA_TOGGLE_SUBTITLES_REQUEST,
- });
- }
- break;
+ // case "c":
+ // event.preventDefault();
+ // if (isVideo && mediaElement.textTracks.length > 0) {
+ // dispatch({
+ // type: MediaActionTypes.MEDIA_TOGGLE_SUBTITLES_REQUEST,
+ // });
+ // }
+ // break;
case "d": {
const hasDownload = mediaElement.querySelector(
@@ -2400,15 +2400,15 @@ function MediaPlayerTime(props: MediaPlayerTimeProps) {
dir={context.dir}
{...timeProps}
className={cn(
- "flex gap-1 items-center text-sm text-white",
+ "flex gap-1 items-center text-sm text-white min-w-fit",
className,
)}
>
- <span className="tabular-nums text-white">{times.current}</span>
- <span role="separator" aria-hidden="true" tabIndex={-1}>
+ <span className="text-xs tabular-nums text-white min-w-fit md:text-base">{times.current}</span>
+ <span className="text-xs tabular-nums text-gray-11" role="separator" aria-hidden="true" tabIndex={-1}>
/
</span>
- <span className="tabular-nums text-white">{times.duration}</span>
+ <span className="text-xs tabular-nums text-white min-w-fit md:text-base">{times.duration}</span>
</TimePrimitive>
);
}
diff --git a/apps/web/components/pages/HomePage/Header.tsx b/apps/web/components/pages/HomePage/Header.tsx
index 80c5cfd68..62c14a06d 100644
--- a/apps/web/components/pages/HomePage/Header.tsx
+++ b/apps/web/components/pages/HomePage/Header.tsx
@@ -185,7 +185,7 @@ const Header = ({ serverHomepageCopyVariant = "" }: HeaderProps) => {
</div>
<motion.div
- className="xl:absolute drop-shadow-2xl -top-[15%] lg:-right-[400px] 2xl:-right-[300px] w-full xl:max-w-[1000px] 2xl:max-w-[1200px]"
+ className="xl:absolute drop-shadow-2xl -top-[22%] lg:-right-[400px] 2xl:-right-[300px] w-full xl:max-w-[1000px] 2xl:max-w-[1200px]"
initial="hidden"
animate="visible"
variants={fadeInFromRight}