diff --git a/components/pages/create-to-video2.tsx b/components/pages/create-to-video2.tsx index 38b980a..094c650 100644 --- a/components/pages/create-to-video2.tsx +++ b/components/pages/create-to-video2.tsx @@ -11,7 +11,7 @@ import cover_image1 from '@/public/assets/cover_image3.jpg'; import { motion } from 'framer-motion'; import { Tooltip, Button } from 'antd'; import { GlassIconButton } from '@/components/ui/glass-icon-button'; -import { downloadVideo } from '@/utils/tools'; +import { downloadVideo, getFirstFrame } from '@/utils/tools'; @@ -210,7 +210,7 @@ export default function CreateToVideo2() { playsInline preload="none" poster={ - project.final_video_url || project.final_simple_video_url ? `${project.final_video_url || project.final_simple_video_url}?vframe/jpg/offset/1` : `${project.video_urls}?x-oss-process=video/snapshot,t_1000,f_jpg` + getFirstFrame(project.final_video_url || project.final_simple_video_url || project.video_urls) } /> ) : ( diff --git a/components/pages/work-flow/media-viewer.tsx b/components/pages/work-flow/media-viewer.tsx index 648a619..419f9ed 100644 --- a/components/pages/work-flow/media-viewer.tsx +++ b/components/pages/work-flow/media-viewer.tsx @@ -10,7 +10,7 @@ import { mockScriptData } from '@/components/script-renderer/mock'; import { Skeleton } from '@/components/ui/skeleton'; import { TaskObject } from '@/api/DTO/movieEdit'; import { Button, Tooltip } from 'antd'; -import { downloadVideo, downloadAllVideos } from '@/utils/tools'; +import { downloadVideo, downloadAllVideos, getFirstFrame } from '@/utils/tools'; interface MediaViewerProps { taskObject: TaskObject; @@ -170,7 +170,7 @@ export const MediaViewer = React.memo(function MediaViewer({ loop playsInline preload="metadata" - poster={`${taskObject.final.url}?vframe/jpg/offset/1`} + poster={getFirstFrame(taskObject.final.url)} onLoadedData={handleFinalVideoLoaded} onPlay={() => setIsFinalVideoPlaying(true)} onPause={() => setIsFinalVideoPlaying(false)} @@ -338,6 +338,8 @@ export const MediaViewer = React.memo(function MediaViewer({ loop playsInline muted + poster={getFirstFrame(taskObject.final.url)} + preload="none" /> @@ -477,6 +479,8 @@ export const MediaViewer = React.memo(function MediaViewer({ key={taskObject.videos.data[currentSketchIndex].urls[0]} className="w-full h-full rounded-lg object-cover object-center relative z-10" src={taskObject.videos.data[currentSketchIndex].urls[0]} + poster={getFirstFrame(taskObject.videos.data[currentSketchIndex].urls[0])} + preload="none" autoPlay={isVideoPlaying} loop={true} playsInline diff --git a/components/pages/work-flow/thumbnail-grid.tsx b/components/pages/work-flow/thumbnail-grid.tsx index 5a4636c..26b4d3b 100644 --- a/components/pages/work-flow/thumbnail-grid.tsx +++ b/components/pages/work-flow/thumbnail-grid.tsx @@ -6,6 +6,7 @@ import { Skeleton } from '@/components/ui/skeleton'; import { ProgressiveReveal, presets } from '@/components/ui/progressive-reveal'; import { Loader2, X, SquareUserRound, MapPinHouse, Clapperboard, Video, RotateCcw } from 'lucide-react'; import { TaskObject } from '@/api/DTO/movieEdit'; +import { getFirstFrame } from '@/utils/tools'; interface ThumbnailGridProps { isDisabledFocus: boolean; @@ -218,7 +219,7 @@ export function ThumbnailGrid({ > video thumbnail @@ -230,6 +231,8 @@ export function ThumbnailGrid({ muted playsInline loop + poster={getFirstFrame(taskObject.videos.data[index].urls[0])} + preload="none" /> )} diff --git a/lib/auth.ts b/lib/auth.ts index 733482c..06a41c2 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -248,19 +248,19 @@ export const validateOAuthState = (state: string): boolean => { * @returns {Promise} 用户信息对象 */ export const getUserProfile = async (): Promise => { - // const t = { - // id: '1', - // userId: '1', - // username: 'test', - // name: 'test', - // email: 'test@test.com', - // role: 'USER', - // isActive: 1, - // authType: 'email', - // lastLogin: new Date(), - // } - // setUser(t); - // return t; + const t = { + id: 'fcb6768b6f49449387e6617f75baabc0', + userId: 'fcb6768b6f49449387e6617f75baabc0', + username: 'gxy', + name: 'gxy', + email: 'moviflow66@test.com', + role: 'USER', + isActive: 1, + authType: 'LOCAL', + lastLogin: new Date(), + } + setUser(t); + return t; try { const token = getToken(); if (!token) { diff --git a/utils/tools.ts b/utils/tools.ts index 8bc2f84..a6f9a93 100644 --- a/utils/tools.ts +++ b/utils/tools.ts @@ -103,4 +103,17 @@ export const downloadAllVideos = async (urls: string[]) => { for (const url of urls) { await downloadVideo(url); } -}; \ No newline at end of file +}; + +/** + * 阿里云地址 七牛云地址 取首帧方式不一样 + * 发现 链接 包含 ‘aliyuncs.com’ 是阿里云地址 + * @param url 视频URL + */ +export const getFirstFrame = (url: string) => { + if (url.includes('aliyuncs.com')) { + return url + '?x-oss-process=video/snapshot,t_1000,f_jpg'; + } else { + return url + '?vframe/jpg/offset/1'; + } +} \ No newline at end of file