Full back end integration

This commit is contained in:
Koper
2023-07-20 00:40:11 +07:00
parent ca75871cd5
commit 0cf929dfa8
9 changed files with 120 additions and 134 deletions

View File

@@ -1,21 +1,4 @@
export default function Record(props) {
let mediaRecorder = null; // mediaRecorder instance
const startRecording = () => {
navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
mediaRecorder = new MediaRecorder(stream);
mediaRecorder.start();
props.onRecord(true);
});
};
const stopRecording = () => {
if (mediaRecorder) {
mediaRecorder.stop();
props.onRecord(false);
}
};
return (
<div className="flex flex-col justify-center h-screen">
<div className="text-center py-6 mt-10">
@@ -25,11 +8,11 @@ export default function Record(props) {
<div className="flex flex-col items-center justify-center flex-grow -mt-10">
{!props.isRecording ? (
<button onClick={startRecording} data-color="blue">
<button onClick={() => props.onRecord(true)} data-color="blue">
Record
</button>
) : (
<button onClick={stopRecording} data-color="red">
<button onClick={() => props.onRecord(false)} data-color="red">
Stop
</button>
)}