Spaces:
Sleeping
Sleeping
Update screen_capture.js
Browse files- screen_capture.js +19 -5
screen_capture.js
CHANGED
|
@@ -6,17 +6,31 @@ async function startScreenCapture() {
|
|
| 6 |
audio: false
|
| 7 |
});
|
| 8 |
|
| 9 |
-
// Conectar el stream a un canvas o video tag para previsualizar si es necesario
|
| 10 |
const videoElement = document.getElementById('screenPreview');
|
| 11 |
if (videoElement) {
|
| 12 |
videoElement.srcObject = stream;
|
|
|
|
| 13 |
}
|
| 14 |
|
| 15 |
-
//
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
} catch (err) {
|
| 19 |
console.error("Error capturando pantalla: ", err);
|
| 20 |
}
|
| 21 |
}
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
audio: false
|
| 7 |
});
|
| 8 |
|
|
|
|
| 9 |
const videoElement = document.getElementById('screenPreview');
|
| 10 |
if (videoElement) {
|
| 11 |
videoElement.srcObject = stream;
|
| 12 |
+
videoElement.play();
|
| 13 |
}
|
| 14 |
|
| 15 |
+
// Conectar el stream de video a un servidor backend a trav茅s de WebRTC o WebSocket para que lo procese FFmpeg
|
| 16 |
+
const mediaRecorder = new MediaRecorder(stream);
|
| 17 |
+
mediaRecorder.ondataavailable = function(event) {
|
| 18 |
+
if (event.data.size > 0) {
|
| 19 |
+
// Aqu铆 deber铆as enviar los datos de video al backend
|
| 20 |
+
sendToBackend(event.data);
|
| 21 |
+
}
|
| 22 |
+
};
|
| 23 |
+
mediaRecorder.start(1000); // Captura datos cada segundo
|
| 24 |
} catch (err) {
|
| 25 |
console.error("Error capturando pantalla: ", err);
|
| 26 |
}
|
| 27 |
}
|
| 28 |
+
|
| 29 |
+
function sendToBackend(data) {
|
| 30 |
+
// L贸gica para enviar el stream al backend
|
| 31 |
+
fetch('/save_stream', {
|
| 32 |
+
method: 'POST',
|
| 33 |
+
body: data
|
| 34 |
+
});
|
| 35 |
+
}
|
| 36 |
+
</script>
|