Commit db63f5e8 authored by supundileepa00's avatar supundileepa00

feat : added video recording component

parent ca4046fa
This diff is collapsed.
...@@ -68,10 +68,12 @@ ...@@ -68,10 +68,12 @@
"react-lazy-load-image-component": "^1.5.5", "react-lazy-load-image-component": "^1.5.5",
"react-map-gl": "^7.0.19", "react-map-gl": "^7.0.19",
"react-markdown": "^8.0.3", "react-markdown": "^8.0.3",
"react-media-recorder": "^1.6.6",
"react-organizational-chart": "^2.2.0", "react-organizational-chart": "^2.2.0",
"react-quill": "^2.0.0", "react-quill": "^2.0.0",
"react-redux": "^8.0.4", "react-redux": "^8.0.4",
"react-slick": "^0.29.0", "react-slick": "^0.29.0",
"react-webcam": "^7.0.1",
"redux": "^4.2.0", "redux": "^4.2.0",
"redux-persist": "^6.0.0", "redux-persist": "^6.0.0",
"rehype-raw": "^6.1.1", "rehype-raw": "^6.1.1",
......
...@@ -10,6 +10,12 @@ import { ...@@ -10,6 +10,12 @@ import {
CardHeader, CardHeader,
Divider, Divider,
Grid, Grid,
TextField,
IconButton,
Typography,
InputAdornment,
Stack,
Tooltip,
} from '@mui/material'; } from '@mui/material';
// layouts // layouts
import MainLayout from '../layouts/main'; import MainLayout from '../layouts/main';
...@@ -22,9 +28,14 @@ import { ...@@ -22,9 +28,14 @@ import {
AboutTestimonials, AboutTestimonials,
} from '../sections/slToText'; } from '../sections/slToText';
import { Upload } from 'src/components/upload'; import { Upload } from 'src/components/upload';
import { useCallback, useState } from 'react'; import { useCallback, useRef, useState } from 'react';
import UploadIcon from '@mui/icons-material/Upload'; import UploadIcon from '@mui/icons-material/Upload';
import EmergencyRecordingIcon from '@mui/icons-material/EmergencyRecording'; import EmergencyRecordingIcon from '@mui/icons-material/EmergencyRecording';
import { useSnackbar } from 'notistack';
import useCopyToClipboard from 'src/hooks/useCopyToClipboard';
import Iconify from 'src/components/iconify/Iconify';
import { useReactMediaRecorder } from 'react-media-recorder';
import dynamic from 'next/dynamic';
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
...@@ -34,6 +45,7 @@ AboutPage.getLayout = (page: React.ReactElement) => <MainLayout>{page}</MainLayo ...@@ -34,6 +45,7 @@ AboutPage.getLayout = (page: React.ReactElement) => <MainLayout>{page}</MainLayo
export default function AboutPage() { export default function AboutPage() {
const [file, setFile] = useState<File | string | null>(null); const [file, setFile] = useState<File | string | null>(null);
const [isUploadFile, setIsUploadFile] = useState<boolean | string | null>(true);
const handleDropSingleFile = useCallback((acceptedFiles: File[]) => { const handleDropSingleFile = useCallback((acceptedFiles: File[]) => {
const file = acceptedFiles[0]; const file = acceptedFiles[0];
...@@ -45,56 +57,136 @@ export default function AboutPage() { ...@@ -45,56 +57,136 @@ export default function AboutPage() {
); );
} }
}, []); }, []);
const checkTranalationTypeForUpload = () => {
if (isUploadFile) {
return 'contained';
} else {
return 'outlined';
}
};
const checkTranalationTypeForRecord = () => {
if (!isUploadFile) {
return 'contained';
} else {
return 'outlined';
}
};
const { enqueueSnackbar } = useSnackbar();
const { copy } = useCopyToClipboard();
const [value, setValue] = useState('ආආආආආආආආආආආආආආආආ');
const onCopy = (text: string) => {
if (text) {
enqueueSnackbar('Copied!');
copy(text);
}
};
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
setValue(event.target.value);
};
return ( return (
<> <>
<Head> <Head>
<title>Translate SSL to Text</title> <title>Translate SSL to Text</title>
</Head> </Head>
<Box sx={{ flexGrow: 1 }}> <ButtonGroup disableElevation variant="contained" aria-label="Disabled elevation buttons">
<ButtonGroup disableElevation variant="contained" aria-label="Disabled elevation buttons"> <Button
<Button variant="outlined" startIcon={<UploadIcon />}> variant={checkTranalationTypeForUpload()}
Upload startIcon={<UploadIcon />}
</Button> onClick={() => {
<Button variant="contained" endIcon={<EmergencyRecordingIcon />}> setIsUploadFile(true);
Send }}
</Button> >
</ButtonGroup> Upload
<Card> </Button>
<Grid <Button
container variant={checkTranalationTypeForRecord()}
spacing={2} endIcon={<EmergencyRecordingIcon />}
sx={{ onClick={() => {
mt: '3%', setIsUploadFile(false);
px: '1%', }}
}} >
> Record
<Grid item xs={12} md={6}> </Button>
<Card> </ButtonGroup>
<CardHeader title="Upload a video containing Sign Language" /> {isUploadFile ? (
<CardContent> <Box sx={{ flexGrow: 1 }}>
<Upload <Card>
file={file} <CardHeader title="Upload a video containing Sign Language" />
onDrop={handleDropSingleFile} <Grid container spacing={2}>
onDelete={() => setFile(null)} <Grid item xs={12} md={6}>
/> <Card>
</CardContent> <CardContent>
</Card> <Upload
</Grid> file={file}
<Grid item xs={12} md={6}> onDrop={handleDropSingleFile}
<Card> onDelete={() => setFile(null)}
<CardHeader title="Upload a video containing Sign Language" /> />
<CardContent> </CardContent>
<Upload </Card>
file={file} </Grid>
onDrop={handleDropSingleFile} <Grid item xs={12} md={6}>
onDelete={() => setFile(null)} <Card sx={{ p: 5 }}>
/> <Box
</CardContent> display="grid"
</Card> gridTemplateColumns={{ xs: 'repeat(1, 1fr)', md: 'repeat(2, 1fr)' }}
gap={5}
>
<Stack spacing={2}>
<Typography variant="overline" sx={{ color: 'text.secondary' }}>
on Change
</Typography>
<TextField
fullWidth
value={value}
onChange={handleChange}
InputProps={{
endAdornment: (
<InputAdornment position="end">
<Tooltip title="Copy">
<IconButton onClick={() => onCopy(value)}>
<Iconify icon="eva:copy-fill" width={24} />
</IconButton>
</Tooltip>
</InputAdornment>
),
}}
/>
</Stack>
</Box>
</Card>
</Grid>
</Grid> </Grid>
</Grid> </Card>
</Card> </Box>
</Box> ) : (
// Video Capture
// <RecordView />
<div>sdsd</div>
)}
</> </>
); );
} }
const RecordView = () => {
const { status, startRecording, stopRecording, mediaBlobUrl } = useReactMediaRecorder({
video: true,
});
return (
<div>
<p>{status}</p>
<button onClick={startRecording}>Start Recording</button>
<button onClick={stopRecording}>Stop Recording</button>
<video src={mediaBlobUrl} controls autoPlay loop />
</div>
);
};
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment