mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-21 15:09:32 +02:00
WIP
- Setted the tool structure and integration with the project
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable prettier/prettier */
|
||||||
import { Box } from '@mui/material';
|
import { Box } from '@mui/material';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import ToolContent from '@components/ToolContent';
|
import ToolContent from '@components/ToolContent';
|
||||||
@@ -8,55 +9,77 @@ import { GetGroupsType } from '@components/options/ToolOptions';
|
|||||||
import { CardExampleType } from '@components/examples/ToolExamples';
|
import { CardExampleType } from '@components/examples/ToolExamples';
|
||||||
import { main } from './service';
|
import { main } from './service';
|
||||||
import { InitialValuesType } from './types';
|
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 = {
|
const initialValues: InitialValuesType = {
|
||||||
// splitSeparator: '\n'
|
newSpeed: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
const exampleCards: CardExampleType<InitialValuesType>[] = [
|
// TODO - Add the ffmpeg logic
|
||||||
{
|
|
||||||
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: ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
export default function ChangeSpeed({
|
export default function ChangeSpeed({
|
||||||
title,
|
title,
|
||||||
longDescription
|
longDescription
|
||||||
}: ToolComponentProps) {
|
}: ToolComponentProps) {
|
||||||
const [input, setInput] = useState<string>('');
|
const [input, setInput] = useState<File | null>(null);
|
||||||
const [result, setResult] = useState<string>('');
|
const [result, setResult] = useState<File | null>(null);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const compute = (values: InitialValuesType, input: string) => {
|
const compute = (optionsValues: InitialValuesType, input: File | null) => {
|
||||||
setResult(main(input, values));
|
if (!input) return;
|
||||||
|
const { newSpeed } = optionsValues;
|
||||||
|
|
||||||
|
// Here we set the output video
|
||||||
|
setResult(main(input, optionsValues));
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGroups: GetGroupsType<InitialValuesType> | null = ({
|
const getGroups: GetGroupsType<InitialValuesType> | null = ({
|
||||||
values,
|
values,
|
||||||
updateField
|
updateField
|
||||||
}) => [
|
}) => [
|
||||||
{
|
{
|
||||||
title: 'Example Settings',
|
title: 'New Video Speed',
|
||||||
component: <Box></Box>
|
component: (
|
||||||
}
|
<Box>
|
||||||
];
|
<TextFieldWithDesc
|
||||||
|
value={values.newSpeed.toString()}
|
||||||
|
onOwnChange={(val) => updateField('newSpeed', Number(val))}
|
||||||
|
description="Default multiplier: 2 means 2x faster"
|
||||||
|
type="number"
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
];
|
||||||
return (
|
return (
|
||||||
<ToolContent
|
<ToolContent
|
||||||
title={title}
|
title={title}
|
||||||
input={input}
|
input={input}
|
||||||
inputComponent={<ToolTextInput value={input} onChange={setInput} />}
|
inputComponent={
|
||||||
resultComponent={<ToolTextResult value={result} />}
|
<ToolVideoInput
|
||||||
|
value={input}
|
||||||
|
onChange={setInput}
|
||||||
|
title={'Input Video'}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
resultComponent={
|
||||||
|
loading ? (
|
||||||
|
<ToolFileResult
|
||||||
|
title="Setting Speed"
|
||||||
|
value={null}
|
||||||
|
loading={true}
|
||||||
|
extension={''}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<ToolFileResult title="Edited Video" value={result} extension="mp4" />
|
||||||
|
)
|
||||||
|
}
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
exampleCards={exampleCards}
|
|
||||||
getGroups={getGroups}
|
getGroups={getGroups}
|
||||||
setInput={setInput}
|
setInput={setInput}
|
||||||
compute={compute}
|
compute={compute}
|
||||||
toolInfo={{ title: `What is a ${title}?`, description: longDescription }}
|
toolInfo={{ title: `What is a ${title}?`, description: longDescription }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -4,10 +4,10 @@ import { lazy } from 'react';
|
|||||||
export const tool = defineTool('video', {
|
export const tool = defineTool('video', {
|
||||||
name: 'Change speed',
|
name: 'Change speed',
|
||||||
path: 'change-speed',
|
path: 'change-speed',
|
||||||
icon: '',
|
icon: 'material-symbols-light:speed-outline',
|
||||||
description: '',
|
description:
|
||||||
shortDescription: '',
|
'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'],
|
keywords: ['change', 'speed'],
|
||||||
longDescription: '',
|
|
||||||
component: lazy(() => import('./index'))
|
component: lazy(() => import('./index'))
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
import { InitialValuesType } from './types';
|
import { InitialValuesType } from './types';
|
||||||
|
|
||||||
export function main(input: string, options: InitialValuesType): string {
|
export function main(
|
||||||
|
input: File | null,
|
||||||
|
options: InitialValuesType
|
||||||
|
): File | null {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
export type InitialValuesType = {
|
export type InitialValuesType = {
|
||||||
// splitSeparator: string;
|
newSpeed: Number;
|
||||||
};
|
};
|
||||||
|
@@ -7,6 +7,7 @@ import { tool as rotateVideo } from './rotate/meta';
|
|||||||
import { tool as compressVideo } from './compress/meta';
|
import { tool as compressVideo } from './compress/meta';
|
||||||
import { tool as loopVideo } from './loop/meta';
|
import { tool as loopVideo } from './loop/meta';
|
||||||
import { tool as flipVideo } from './flip/meta';
|
import { tool as flipVideo } from './flip/meta';
|
||||||
|
import { tool as changeSpeed } from './change-speed/meta';
|
||||||
|
|
||||||
export const videoTools = [
|
export const videoTools = [
|
||||||
...gifTools,
|
...gifTools,
|
||||||
@@ -14,5 +15,6 @@ export const videoTools = [
|
|||||||
rotateVideo,
|
rotateVideo,
|
||||||
compressVideo,
|
compressVideo,
|
||||||
loopVideo,
|
loopVideo,
|
||||||
flipVideo
|
flipVideo,
|
||||||
|
changeSpeed
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user