migrate recording tab to new media player

This commit is contained in:
MarconLP 2024-11-20 23:46:00 +01:00
parent 458b3f0c1b
commit cfb5466494
No known key found for this signature in database
GPG key ID: A08A9C8B623F5EA5
4 changed files with 22 additions and 51 deletions

View file

@ -18,6 +18,7 @@ import { usePostHog } from "posthog-js/react";
import Tooltip from "~/components/Tooltip"; import Tooltip from "~/components/Tooltip";
import generateThumbnail from "~/utils/generateThumbnail"; import generateThumbnail from "~/utils/generateThumbnail";
import * as EBML from "ts-ebml"; import * as EBML from "ts-ebml";
import VideoPlayer from "~/components/VideoPlayer";
interface Props { interface Props {
closeModal: () => void; closeModal: () => void;
@ -200,7 +201,7 @@ export default function Recorder({ closeModal, step, setStep }: Props) {
const handleSave = () => { const handleSave = () => {
if (blob) { if (blob) {
const dateString = const dateString =
"Recording - " + dayjs().format("D MMM YYYY") + ".webm"; "Snapify Recording - " + dayjs().format("D MMM YYYY") + ".webm";
invokeSaveAsDialog(blob, dateString); invokeSaveAsDialog(blob, dateString);
} }
@ -210,7 +211,8 @@ export default function Recorder({ closeModal, step, setStep }: Props) {
const handleUpload = async () => { const handleUpload = async () => {
if (!blob || !videoRef.current) return; if (!blob || !videoRef.current) return;
const dateString = "Recording - " + dayjs().format("D MMM YYYY") + ".webm"; const dateString =
"Snapify Recording - " + dayjs().format("D MMM YYYY") + ".webm";
setSubmitting(true); setSubmitting(true);
try { try {
@ -390,15 +392,14 @@ export default function Recorder({ closeModal, step, setStep }: Props) {
{step === "post" ? ( {step === "post" ? (
<div> <div>
{blob ? ( {blob ? (
<video <div className="mb-3 aspect-video max-h-[75vh] max-w-[75vw]">
src={URL.createObjectURL(blob)} <VideoPlayer video_url={URL.createObjectURL(blob)} />
controls <video
onPlay={() => posthog?.capture("recorder: played preview video")} src={URL.createObjectURL(blob)}
onPause={() => posthog?.capture("recorder: paused preview video")} ref={videoRef}
ref={videoRef} className="absolute hidden"
className="mb-4 max-h-[75vh] w-[75vw]" />
controlsList="nodownload" </div>
/>
) : null} ) : null}
<div className="flex items-center justify-center"> <div className="flex items-center justify-center">
<button <button

View file

@ -17,9 +17,9 @@ export function VideoLayout({ thumbnails }: VideoLayoutProps) {
<> <>
<Gestures /> <Gestures />
<Controls.Root <Controls.Root
hideDelay={50} hideDelay={500}
hideOnMouseLeave={true} hideOnMouseLeave={true}
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" 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"
> >
<Tooltip.Provider> <Tooltip.Provider>
<div className="flex-1" /> <div className="flex-1" />

View file

@ -18,7 +18,7 @@ import { VideoLayout } from "./VideoLayout";
interface Props { interface Props {
video_url: string; video_url: string;
thumbnailUrl: string; thumbnailUrl?: string;
} }
export default function VideoPlayer({ video_url, thumbnailUrl }: Props) { export default function VideoPlayer({ video_url, thumbnailUrl }: Props) {
@ -68,11 +68,13 @@ export default function VideoPlayer({ video_url, thumbnailUrl }: Props) {
keyTarget="document" keyTarget="document"
> >
<MediaProvider> <MediaProvider>
<Poster {thumbnailUrl ? (
className="absolute inset-0 block h-full w-full rounded-md object-cover opacity-0 transition-opacity data-[visible]:opacity-100" <Poster
src={thumbnailUrl} className="absolute inset-0 block h-full w-full rounded-md object-cover opacity-0 transition-opacity data-[visible]:opacity-100"
alt="Girl walks into campfire with gnomes surrounding her friend ready for their next meal!" src={thumbnailUrl}
/> alt="video thumbnail"
/>
) : null}
</MediaProvider> </MediaProvider>
<VideoLayout /> <VideoLayout />

View file

@ -138,38 +138,6 @@ const VideoList: NextPage = () => {
thumbnailUrl={video.thumbnailUrl} thumbnailUrl={video.thumbnailUrl}
video_url={video.video_url} video_url={video.video_url}
/> />
{/*<video*/}
{/* controls*/}
{/* onPlay={() =>*/}
{/* posthog?.capture("play video", {*/}
{/* videoId: video.id,*/}
{/* videoCreatedAt: video.createdAt,*/}
{/* videoUpdatedAt: video.updatedAt,*/}
{/* videoUser: video.user.id,*/}
{/* videoSharing: video.sharing,*/}
{/* videoDeleteAfterLinkExpires:*/}
{/* video.delete_after_link_expires,*/}
{/* videoShareLinkExpiresAt: video.shareLinkExpiresAt,*/}
{/* })*/}
{/* }*/}
{/* onPause={() =>*/}
{/* posthog?.capture("pause video", {*/}
{/* videoId: video.id,*/}
{/* videoCreatedAt: video.createdAt,*/}
{/* videoUpdatedAt: video.updatedAt,*/}
{/* videoUser: video.user.id,*/}
{/* videoSharing: video.sharing,*/}
{/* videoDeleteAfterLinkExpires:*/}
{/* video.delete_after_link_expires,*/}
{/* videoShareLinkExpiresAt: video.shareLinkExpiresAt,*/}
{/* })*/}
{/* }*/}
{/* className="h-full w-full"*/}
{/* controlsList="nodownload"*/}
{/*>*/}
{/* <source src={video.video_url} />*/}
{/* Your browser does not support the video tag.*/}
{/*</video>*/}
</> </>
)} )}
</div> </div>