Skip to content

Commit

Permalink
feat: cache videos for one week and use ingread video in scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
micksabox committed Jun 18, 2024
1 parent e6636e0 commit fa25347
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 19 additions & 1 deletion app/routes/ingread/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useRef, useState, useCallback, useEffect } from 'react'
import Webcam from 'react-webcam'
import { Button } from 'src/components/ui/button'
import { useFetcher, useRouteError } from '@remix-run/react'
import { ActionFunctionArgs, LoaderFunctionArgs, json } from '@remix-run/node'
import { ActionFunctionArgs, LinksFunction, LoaderFunctionArgs, json } from '@remix-run/node'
import { invariantResponse } from 'src/utils/misc'
import { openai } from 'src/lib/openai.server'
import { clsx } from 'clsx'
Expand All @@ -25,6 +25,17 @@ const videoConstraints = {
},
}

export const links: LinksFunction = () => {
return [
{
rel: 'preload',
href: '/videos/watermarked_video0c3be294294da4ad89c2509dce30c8bb2.mp4',
as: 'video',
type: 'video/mp4',
},
]
}

export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url)
const entrypoint = url.searchParams.get('entry')
Expand Down Expand Up @@ -155,6 +166,13 @@ const CameraCapture: React.FC = () => {
style={{ height: rootWidth }}
className="mx-auto flex max-h-[512px] w-full max-w-[512px] items-center justify-center bg-gray-200"
>
<video
src="/videos/watermarked_video0c3be294294da4ad89c2509dce30c8bb2.mp4"
playsInline
autoPlay
loop
className="w-full"
/>
<VideoIcon className="h-48 w-48 text-gray-300" />
</div>
)}
Expand Down
6 changes: 3 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ export default defineConfig(async () => {
},
},
plugins: [
mdx.default({
remarkPlugins: [remarkFrontmatter.default, remarkMdxFrontmatter.default],
}),
remix({
async routes(defineRoutes) {
return flatRoutes('routes', defineRoutes)
},
}),
svgr({}),
mdx.default({
remarkPlugins: [remarkFrontmatter.default, remarkMdxFrontmatter.default],
}),
tsconfigPaths(),
],
resolve: {
Expand Down

0 comments on commit fa25347

Please sign in to comment.