forked from 77media/video-flow
兼容 不同cdn链接获取首帧
This commit is contained in:
parent
9365896bb6
commit
9345cc40c2
@ -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)
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
|
||||
@ -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"
|
||||
/>
|
||||
</motion.div>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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({
|
||||
>
|
||||
<img
|
||||
className="w-full h-full object-cover"
|
||||
src={`${taskObject.videos.data[index].urls[0]}?x-oss-process=video/snapshot,t_1000,f_jpg`}
|
||||
src={getFirstFrame(taskObject.videos.data[index].urls[0])}
|
||||
draggable="false"
|
||||
alt="video thumbnail"
|
||||
/>
|
||||
@ -230,6 +231,8 @@ export function ThumbnailGrid({
|
||||
muted
|
||||
playsInline
|
||||
loop
|
||||
poster={getFirstFrame(taskObject.videos.data[index].urls[0])}
|
||||
preload="none"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
26
lib/auth.ts
26
lib/auth.ts
@ -248,19 +248,19 @@ export const validateOAuthState = (state: string): boolean => {
|
||||
* @returns {Promise<any>} 用户信息对象
|
||||
*/
|
||||
export const getUserProfile = async (): Promise<any> => {
|
||||
// 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) {
|
||||
|
||||
@ -103,4 +103,17 @@ export const downloadAllVideos = async (urls: string[]) => {
|
||||
for (const url of urls) {
|
||||
await downloadVideo(url);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 阿里云地址 七牛云地址 取首帧方式不一样
|
||||
* 发现 链接 包含 ‘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';
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user