mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-21 06:59:33 +02:00
feat: add audio extraction tool to convert video files to audio formats (AAC, MP3, WAV)
This commit is contained in:
46
src/components/input/ToolAudioInput.tsx
Normal file
46
src/components/input/ToolAudioInput.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import React, { useRef } from 'react';
|
||||
import { Box, Typography } from '@mui/material';
|
||||
import BaseFileInput from './BaseFileInput';
|
||||
import { BaseFileInputProps } from './file-input-utils';
|
||||
|
||||
interface AudioFileInputProps extends Omit<BaseFileInputProps, 'accept'> {
|
||||
accept?: string[];
|
||||
}
|
||||
|
||||
export default function ToolAudioInput({
|
||||
accept = ['audio/*', '.mp3', '.wav', '.aac'],
|
||||
...props
|
||||
}: AudioFileInputProps) {
|
||||
const audioRef = useRef<HTMLAudioElement>(null);
|
||||
|
||||
return (
|
||||
<BaseFileInput {...props} type={'audio'} accept={accept}>
|
||||
{({ preview }) => (
|
||||
<Box
|
||||
sx={{
|
||||
position: 'relative',
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center'
|
||||
}}
|
||||
>
|
||||
{preview ? (
|
||||
<audio
|
||||
ref={audioRef}
|
||||
src={preview}
|
||||
style={{ maxWidth: '100%' }}
|
||||
controls
|
||||
/>
|
||||
) : (
|
||||
<Typography variant="body2" color="textSecondary">
|
||||
Drag & drop or import an audio file
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</BaseFileInput>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user