From f9bb10ff1ef4b4f7a98f9f8bea6459909d4bde0e Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 27 May 2021 20:14:02 +0200 Subject: [PATCH] Support click on/off recording --- voicegardens/static/voicegardens.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/voicegardens/static/voicegardens.js b/voicegardens/static/voicegardens.js index 30a06ac..0132e35 100644 --- a/voicegardens/static/voicegardens.js +++ b/voicegardens/static/voicegardens.js @@ -4,6 +4,12 @@ // Voicegardens front-end Javascript // +// The entire canvas +var _canvas; + +// Offline recording duration +var offlineRecordingDuration = 6000; + // URL which exposes the archive saving API end-point var archiveUrl = window.location + "add-to-archive"; var archiveListingUrl = window.location + "archive"; @@ -60,6 +66,7 @@ function record() { getAudioContext().resume(); if (microphone.enabled === true) { recorder.record(recording); + setTimeout(stop, offlineRecordingDuration); } } @@ -152,6 +159,8 @@ function setupRecording() { recording = new p5.SoundFile(); + canvas.mousePressed(record); + // recordButton = createImg("../static/images/RECORD-COLOR.png"); // recordButton.mousePressed(record); // recordButton.class("button record"); @@ -506,7 +515,7 @@ function setup() { /** * The initial setup function called once on start. **/ - createCanvas(windowWidth, windowHeight); + canvas = createCanvas(windowWidth, windowHeight); frameRate(frameRate); setupRecording();