Skip to content

Commit cfb5466

Browse files
committed
migrate recording tab to new media player
1 parent 458b3f0 commit cfb5466

File tree

4 files changed

+22
-51
lines changed

4 files changed

+22
-51
lines changed

src/components/Recorder.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { usePostHog } from "posthog-js/react";
1818
import Tooltip from "~/components/Tooltip";
1919
import generateThumbnail from "~/utils/generateThumbnail";
2020
import * as EBML from "ts-ebml";
21+
import VideoPlayer from "~/components/VideoPlayer";
2122

2223
interface Props {
2324
closeModal: () => void;
@@ -200,7 +201,7 @@ export default function Recorder({ closeModal, step, setStep }: Props) {
200201
const handleSave = () => {
201202
if (blob) {
202203
const dateString =
203-
"Recording - " + dayjs().format("D MMM YYYY") + ".webm";
204+
"Snapify Recording - " + dayjs().format("D MMM YYYY") + ".webm";
204205
invokeSaveAsDialog(blob, dateString);
205206
}
206207

@@ -210,7 +211,8 @@ export default function Recorder({ closeModal, step, setStep }: Props) {
210211
const handleUpload = async () => {
211212
if (!blob || !videoRef.current) return;
212213

213-
const dateString = "Recording - " + dayjs().format("D MMM YYYY") + ".webm";
214+
const dateString =
215+
"Snapify Recording - " + dayjs().format("D MMM YYYY") + ".webm";
214216
setSubmitting(true);
215217

216218
try {
@@ -390,15 +392,14 @@ export default function Recorder({ closeModal, step, setStep }: Props) {
390392
{step === "post" ? (
391393
<div>
392394
{blob ? (
393-
<video
394-
src={URL.createObjectURL(blob)}
395-
controls
396-
onPlay={() => posthog?.capture("recorder: played preview video")}
397-
onPause={() => posthog?.capture("recorder: paused preview video")}
398-
ref={videoRef}
399-
className="mb-4 max-h-[75vh] w-[75vw]"
400-
controlsList="nodownload"
401-
/>
395+
<div className="mb-3 aspect-video max-h-[75vh] max-w-[75vw]">
396+
<VideoPlayer video_url={URL.createObjectURL(blob)} />
397+
<video
398+
src={URL.createObjectURL(blob)}
399+
ref={videoRef}
400+
className="absolute hidden"
401+
/>
402+
</div>
402403
) : null}
403404
<div className="flex items-center justify-center">
404405
<button

src/components/VideoLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export function VideoLayout({ thumbnails }: VideoLayoutProps) {
1717
<>
1818
<Gestures />
1919
<Controls.Root
20-
hideDelay={50}
20+
hideDelay={500}
2121
hideOnMouseLeave={true}
22-
className="absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent opacity-0 transition-opacity duration-300 media-controls:opacity-100"
22+
className="absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent opacity-0 transition-opacity duration-300 media-controls:opacity-100 media-paused:opacity-100"
2323
>
2424
<Tooltip.Provider>
2525
<div className="flex-1" />

src/components/VideoPlayer.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { VideoLayout } from "./VideoLayout";
1818

1919
interface Props {
2020
video_url: string;
21-
thumbnailUrl: string;
21+
thumbnailUrl?: string;
2222
}
2323

2424
export default function VideoPlayer({ video_url, thumbnailUrl }: Props) {
@@ -68,11 +68,13 @@ export default function VideoPlayer({ video_url, thumbnailUrl }: Props) {
6868
keyTarget="document"
6969
>
7070
<MediaProvider>
71-
<Poster
72-
className="absolute inset-0 block h-full w-full rounded-md object-cover opacity-0 transition-opacity data-[visible]:opacity-100"
73-
src={thumbnailUrl}
74-
alt="Girl walks into campfire with gnomes surrounding her friend ready for their next meal!"
75-
/>
71+
{thumbnailUrl ? (
72+
<Poster
73+
className="absolute inset-0 block h-full w-full rounded-md object-cover opacity-0 transition-opacity data-[visible]:opacity-100"
74+
src={thumbnailUrl}
75+
alt="video thumbnail"
76+
/>
77+
) : null}
7678
</MediaProvider>
7779

7880
<VideoLayout />

src/pages/share/[videoId].tsx

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -138,38 +138,6 @@ const VideoList: NextPage = () => {
138138
thumbnailUrl={video.thumbnailUrl}
139139
video_url={video.video_url}
140140
/>
141-
{/*<video*/}
142-
{/* controls*/}
143-
{/* onPlay={() =>*/}
144-
{/* posthog?.capture("play video", {*/}
145-
{/* videoId: video.id,*/}
146-
{/* videoCreatedAt: video.createdAt,*/}
147-
{/* videoUpdatedAt: video.updatedAt,*/}
148-
{/* videoUser: video.user.id,*/}
149-
{/* videoSharing: video.sharing,*/}
150-
{/* videoDeleteAfterLinkExpires:*/}
151-
{/* video.delete_after_link_expires,*/}
152-
{/* videoShareLinkExpiresAt: video.shareLinkExpiresAt,*/}
153-
{/* })*/}
154-
{/* }*/}
155-
{/* onPause={() =>*/}
156-
{/* posthog?.capture("pause video", {*/}
157-
{/* videoId: video.id,*/}
158-
{/* videoCreatedAt: video.createdAt,*/}
159-
{/* videoUpdatedAt: video.updatedAt,*/}
160-
{/* videoUser: video.user.id,*/}
161-
{/* videoSharing: video.sharing,*/}
162-
{/* videoDeleteAfterLinkExpires:*/}
163-
{/* video.delete_after_link_expires,*/}
164-
{/* videoShareLinkExpiresAt: video.shareLinkExpiresAt,*/}
165-
{/* })*/}
166-
{/* }*/}
167-
{/* className="h-full w-full"*/}
168-
{/* controlsList="nodownload"*/}
169-
{/*>*/}
170-
{/* <source src={video.video_url} />*/}
171-
{/* Your browser does not support the video tag.*/}
172-
{/*</video>*/}
173141
</>
174142
)}
175143
</div>

0 commit comments

Comments
 (0)