mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
yarn format
This commit is contained in:
54
app/page.js
54
app/page.js
@@ -1,49 +1,55 @@
|
||||
"use client"
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import Record from './components/record.js';
|
||||
import { Dashboard } from './components/dashboard.js';
|
||||
import useWebRTC from './components/webrtc.js';
|
||||
"use client";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import Record from "./components/record.js";
|
||||
import { Dashboard } from "./components/dashboard.js";
|
||||
import useWebRTC from "./components/webrtc.js";
|
||||
|
||||
const App = () => {
|
||||
const [isRecording, setIsRecording] = useState(false);
|
||||
const [splashScreen, setSplashScreen] = useState(true);
|
||||
|
||||
|
||||
|
||||
|
||||
const handleRecord = (recording) => {
|
||||
console.log("handleRecord", recording);
|
||||
|
||||
setIsRecording(recording);
|
||||
setSplashScreen(false);
|
||||
|
||||
if (recording)
|
||||
{
|
||||
navigator.mediaDevices.getUserMedia({ audio: true })
|
||||
if (recording) {
|
||||
navigator.mediaDevices
|
||||
.getUserMedia({ audio: true })
|
||||
.then(setStream)
|
||||
.catch(err => console.error(err));
|
||||
.catch((err) => console.error(err));
|
||||
} else if (!recording) {
|
||||
if (stream) {
|
||||
const tracks = stream.getTracks();
|
||||
tracks.forEach(track => track.stop());
|
||||
tracks.forEach((track) => track.stop());
|
||||
setStream(null);
|
||||
}
|
||||
|
||||
setIsRecording(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const [stream, setStream] = useState(null);
|
||||
const serverData = useWebRTC(stream);
|
||||
console.log(serverData);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center min-h-screen bg-gray-100">
|
||||
{splashScreen && <Record isRecording={isRecording} onRecord={(recording) => handleRecord(recording)} /> }
|
||||
{!splashScreen && <Dashboard isRecording={isRecording} onRecord={(recording) => handleRecord(recording)} />}
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center min-h-screen bg-gray-100">
|
||||
{splashScreen && (
|
||||
<Record
|
||||
isRecording={isRecording}
|
||||
onRecord={(recording) => handleRecord(recording)}
|
||||
/>
|
||||
)}
|
||||
{!splashScreen && (
|
||||
<Dashboard
|
||||
isRecording={isRecording}
|
||||
onRecord={(recording) => handleRecord(recording)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default App;
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user