From e064689e35499baaa30a03744dbe2ff0dad050c0 Mon Sep 17 00:00:00 2001 From: C043 Date: Thu, 22 May 2025 23:34:17 +0200 Subject: [PATCH] WIP - Setted the tool structure and integration with the project --- src/pages/tools/video/change-speed/index.tsx | 75 ++++++++++++------- src/pages/tools/video/change-speed/meta.ts | 10 +-- src/pages/tools/video/change-speed/service.ts | 7 +- src/pages/tools/video/change-speed/types.ts | 4 +- src/pages/tools/video/index.ts | 4 +- 5 files changed, 64 insertions(+), 36 deletions(-) diff --git a/src/pages/tools/video/change-speed/index.tsx b/src/pages/tools/video/change-speed/index.tsx index cb14482..6222af1 100644 --- a/src/pages/tools/video/change-speed/index.tsx +++ b/src/pages/tools/video/change-speed/index.tsx @@ -1,3 +1,4 @@ +/* eslint-disable prettier/prettier */ import { Box } from '@mui/material'; import React, { useState } from 'react'; import ToolContent from '@components/ToolContent'; @@ -8,55 +9,77 @@ import { GetGroupsType } from '@components/options/ToolOptions'; import { CardExampleType } from '@components/examples/ToolExamples'; import { main } from './service'; import { InitialValuesType } from './types'; +import ToolVideoInput from '@components/input/ToolVideoInput'; +import ToolFileResult from '@components/result/ToolFileResult'; +import TextFieldWithDesc from '@components/options/TextFieldWithDesc'; const initialValues: InitialValuesType = { - // splitSeparator: '\n' + newSpeed: 2 }; -const exampleCards: CardExampleType[] = [ - { - title: 'Split a String', - description: 'This example shows how to split a string into multiple lines', - sampleText: 'Hello World,Hello World', - sampleResult: `Hello World -Hello World`, - sampleOptions: { - // splitSeparator: ',' - } - } -]; +// TODO - Add the ffmpeg logic export default function ChangeSpeed({ title, longDescription }: ToolComponentProps) { - const [input, setInput] = useState(''); - const [result, setResult] = useState(''); + const [input, setInput] = useState(null); + const [result, setResult] = useState(null); + const [loading, setLoading] = useState(false); - const compute = (values: InitialValuesType, input: string) => { - setResult(main(input, values)); + const compute = (optionsValues: InitialValuesType, input: File | null) => { + if (!input) return; + const { newSpeed } = optionsValues; + + // Here we set the output video + setResult(main(input, optionsValues)); }; const getGroups: GetGroupsType | null = ({ values, updateField }) => [ - { - title: 'Example Settings', - component: - } - ]; + { + title: 'New Video Speed', + component: ( + + updateField('newSpeed', Number(val))} + description="Default multiplier: 2 means 2x faster" + type="number" + /> + + ) + } + ]; return ( } - resultComponent={} + inputComponent={ + + } + resultComponent={ + loading ? ( + + ) : ( + + ) + } initialValues={initialValues} - exampleCards={exampleCards} getGroups={getGroups} setInput={setInput} compute={compute} toolInfo={{ title: `What is a ${title}?`, description: longDescription }} /> ); -} \ No newline at end of file +} diff --git a/src/pages/tools/video/change-speed/meta.ts b/src/pages/tools/video/change-speed/meta.ts index 15b9c88..37a88d8 100644 --- a/src/pages/tools/video/change-speed/meta.ts +++ b/src/pages/tools/video/change-speed/meta.ts @@ -4,10 +4,10 @@ import { lazy } from 'react'; export const tool = defineTool('video', { name: 'Change speed', path: 'change-speed', - icon: '', - description: '', - shortDescription: '', + icon: 'material-symbols-light:speed-outline', + description: + 'This online utility lets you change the speed of a video. You can speed it up or slow it down.', + shortDescription: 'Quickly change VIDEO speed', keywords: ['change', 'speed'], - longDescription: '', component: lazy(() => import('./index')) -}); \ No newline at end of file +}); diff --git a/src/pages/tools/video/change-speed/service.ts b/src/pages/tools/video/change-speed/service.ts index 182e773..18d6dd6 100644 --- a/src/pages/tools/video/change-speed/service.ts +++ b/src/pages/tools/video/change-speed/service.ts @@ -1,5 +1,8 @@ import { InitialValuesType } from './types'; -export function main(input: string, options: InitialValuesType): string { +export function main( + input: File | null, + options: InitialValuesType +): File | null { return input; -} \ No newline at end of file +} diff --git a/src/pages/tools/video/change-speed/types.ts b/src/pages/tools/video/change-speed/types.ts index 861f1c6..a673625 100644 --- a/src/pages/tools/video/change-speed/types.ts +++ b/src/pages/tools/video/change-speed/types.ts @@ -1,3 +1,3 @@ export type InitialValuesType = { - // splitSeparator: string; -}; \ No newline at end of file + newSpeed: Number; +}; diff --git a/src/pages/tools/video/index.ts b/src/pages/tools/video/index.ts index 4c4316d..d3507f2 100644 --- a/src/pages/tools/video/index.ts +++ b/src/pages/tools/video/index.ts @@ -7,6 +7,7 @@ import { tool as rotateVideo } from './rotate/meta'; import { tool as compressVideo } from './compress/meta'; import { tool as loopVideo } from './loop/meta'; import { tool as flipVideo } from './flip/meta'; +import { tool as changeSpeed } from './change-speed/meta'; export const videoTools = [ ...gifTools, @@ -14,5 +15,6 @@ export const videoTools = [ rotateVideo, compressVideo, loopVideo, - flipVideo + flipVideo, + changeSpeed ];