From 7085765b85ed18deafb26b40bb31f7c7c4ca2cf2 Mon Sep 17 00:00:00 2001 From: TLAlice Date: Tue, 11 Jan 2022 11:20:54 -0300 Subject: [PATCH] Allow recording of videos at any duration Changed the recordVideo function so that instead of pressing record and then recording for 4 seconds, gameplay starts being recorded upon pressing record until pressing it again --- runtimes/web/src/index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/runtimes/web/src/index.js b/runtimes/web/src/index.js index 9bb1fa68..f37c9d46 100644 --- a/runtimes/web/src/index.js +++ b/runtimes/web/src/index.js @@ -121,8 +121,11 @@ async function loadCartWasm () { let videoRecorder = null; function recordVideo () { - if (videoRecorder != null) { - return; // Still recording, ignore + if (videoRecorder != null) { // Stops recording after hitting the record key during recording + videoRecorder.requestData(); + videoRecorder.stop(); + videoRecorder = null; + return; } const mimeType = "video/webm"; @@ -148,11 +151,7 @@ async function loadCartWasm () { }; videoRecorder.start(); - setTimeout(() => { - videoRecorder.requestData(); - videoRecorder.stop(); - videoRecorder = null; - }, 4000); + } let savedState = null;