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 { motion } from 'framer-motion';
|
||||||
import { Tooltip, Button } from 'antd';
|
import { Tooltip, Button } from 'antd';
|
||||||
import { GlassIconButton } from '@/components/ui/glass-icon-button';
|
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
|
playsInline
|
||||||
preload="none"
|
preload="none"
|
||||||
poster={
|
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 { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { TaskObject } from '@/api/DTO/movieEdit';
|
import { TaskObject } from '@/api/DTO/movieEdit';
|
||||||
import { Button, Tooltip } from 'antd';
|
import { Button, Tooltip } from 'antd';
|
||||||
import { downloadVideo, downloadAllVideos } from '@/utils/tools';
|
import { downloadVideo, downloadAllVideos, getFirstFrame } from '@/utils/tools';
|
||||||
|
|
||||||
interface MediaViewerProps {
|
interface MediaViewerProps {
|
||||||
taskObject: TaskObject;
|
taskObject: TaskObject;
|
||||||
@ -170,7 +170,7 @@ export const MediaViewer = React.memo(function MediaViewer({
|
|||||||
loop
|
loop
|
||||||
playsInline
|
playsInline
|
||||||
preload="metadata"
|
preload="metadata"
|
||||||
poster={`${taskObject.final.url}?vframe/jpg/offset/1`}
|
poster={getFirstFrame(taskObject.final.url)}
|
||||||
onLoadedData={handleFinalVideoLoaded}
|
onLoadedData={handleFinalVideoLoaded}
|
||||||
onPlay={() => setIsFinalVideoPlaying(true)}
|
onPlay={() => setIsFinalVideoPlaying(true)}
|
||||||
onPause={() => setIsFinalVideoPlaying(false)}
|
onPause={() => setIsFinalVideoPlaying(false)}
|
||||||
@ -338,6 +338,8 @@ export const MediaViewer = React.memo(function MediaViewer({
|
|||||||
loop
|
loop
|
||||||
playsInline
|
playsInline
|
||||||
muted
|
muted
|
||||||
|
poster={getFirstFrame(taskObject.final.url)}
|
||||||
|
preload="none"
|
||||||
/>
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
@ -477,6 +479,8 @@ export const MediaViewer = React.memo(function MediaViewer({
|
|||||||
key={taskObject.videos.data[currentSketchIndex].urls[0]}
|
key={taskObject.videos.data[currentSketchIndex].urls[0]}
|
||||||
className="w-full h-full rounded-lg object-cover object-center relative z-10"
|
className="w-full h-full rounded-lg object-cover object-center relative z-10"
|
||||||
src={taskObject.videos.data[currentSketchIndex].urls[0]}
|
src={taskObject.videos.data[currentSketchIndex].urls[0]}
|
||||||
|
poster={getFirstFrame(taskObject.videos.data[currentSketchIndex].urls[0])}
|
||||||
|
preload="none"
|
||||||
autoPlay={isVideoPlaying}
|
autoPlay={isVideoPlaying}
|
||||||
loop={true}
|
loop={true}
|
||||||
playsInline
|
playsInline
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { Skeleton } from '@/components/ui/skeleton';
|
|||||||
import { ProgressiveReveal, presets } from '@/components/ui/progressive-reveal';
|
import { ProgressiveReveal, presets } from '@/components/ui/progressive-reveal';
|
||||||
import { Loader2, X, SquareUserRound, MapPinHouse, Clapperboard, Video, RotateCcw } from 'lucide-react';
|
import { Loader2, X, SquareUserRound, MapPinHouse, Clapperboard, Video, RotateCcw } from 'lucide-react';
|
||||||
import { TaskObject } from '@/api/DTO/movieEdit';
|
import { TaskObject } from '@/api/DTO/movieEdit';
|
||||||
|
import { getFirstFrame } from '@/utils/tools';
|
||||||
|
|
||||||
interface ThumbnailGridProps {
|
interface ThumbnailGridProps {
|
||||||
isDisabledFocus: boolean;
|
isDisabledFocus: boolean;
|
||||||
@ -218,7 +219,7 @@ export function ThumbnailGrid({
|
|||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className="w-full h-full object-cover"
|
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"
|
draggable="false"
|
||||||
alt="video thumbnail"
|
alt="video thumbnail"
|
||||||
/>
|
/>
|
||||||
@ -230,6 +231,8 @@ export function ThumbnailGrid({
|
|||||||
muted
|
muted
|
||||||
playsInline
|
playsInline
|
||||||
loop
|
loop
|
||||||
|
poster={getFirstFrame(taskObject.videos.data[index].urls[0])}
|
||||||
|
preload="none"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
26
lib/auth.ts
26
lib/auth.ts
@ -248,19 +248,19 @@ export const validateOAuthState = (state: string): boolean => {
|
|||||||
* @returns {Promise<any>} 用户信息对象
|
* @returns {Promise<any>} 用户信息对象
|
||||||
*/
|
*/
|
||||||
export const getUserProfile = async (): Promise<any> => {
|
export const getUserProfile = async (): Promise<any> => {
|
||||||
// const t = {
|
const t = {
|
||||||
// id: '1',
|
id: 'fcb6768b6f49449387e6617f75baabc0',
|
||||||
// userId: '1',
|
userId: 'fcb6768b6f49449387e6617f75baabc0',
|
||||||
// username: 'test',
|
username: 'gxy',
|
||||||
// name: 'test',
|
name: 'gxy',
|
||||||
// email: 'test@test.com',
|
email: 'moviflow66@test.com',
|
||||||
// role: 'USER',
|
role: 'USER',
|
||||||
// isActive: 1,
|
isActive: 1,
|
||||||
// authType: 'email',
|
authType: 'LOCAL',
|
||||||
// lastLogin: new Date(),
|
lastLogin: new Date(),
|
||||||
// }
|
}
|
||||||
// setUser(t);
|
setUser(t);
|
||||||
// return t;
|
return t;
|
||||||
try {
|
try {
|
||||||
const token = getToken();
|
const token = getToken();
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
|||||||
@ -104,3 +104,16 @@ export const downloadAllVideos = async (urls: string[]) => {
|
|||||||
await downloadVideo(url);
|
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