PennController for IBEX › Forums › Support › Automatically start recording at end of trial and have a submit button
Tagged: audio, media recording
- This topic has 4 replies, 2 voices, and was last updated 3 years, 11 months ago by
adamliter.
-
AuthorPosts
-
February 27, 2021 at 10:57 pm #6673
adamliter
ParticipantIs there a good way to have a trial with an audio recording component that starts automatically and then the participant can click some sort of “submit” button once they are done. The closest I’ve got is the following. With the following code, the recording starts automatically as intended, but then the button that shows up next says “record”. When you click that button, it does save and submit the recording, but is there some way to change the button to say something like “Submit” or “Save recording” so that it is more intuitive for the participant?
PennController.Template("test.csv", row => newTrial("trials", defaultText .settings.center() .print() , newController("DashedSentence", {s: row.Sentence, display: "in place", mode: "speeded acceptability", wordTime: 300, wordPauseTime: 100}) .print() .wait() .log() .remove() , newText("math-problem", "1 + 1") , newTextInput("math-answer", "") .settings.log() .settings.length(4) .print() , newButton("send-math-prob-answer", "Submit") .print() .wait() .remove() , clear() , newMediaRecorder("recorder", "audio") .log() .once() .record() .wait() ) .log("ParticipantID", ParticipantID) .log("Sentence", '"' + row.Sentence + '"') );
March 1, 2021 at 1:30 pm #6679Jeremy
KeymasterHi,
The code you posted will not show any button, because there is no print command in the script after clear has been executed. Why don’t you remove the last wait command (on the MediaRecorder element) and create a “Save recording” button?
newMediaRecorder("recorder", "audio") .log() .once() .record() // .wait() , newButton("Save recording") .callback(getMediaRecorder("recorder").stop()) .print() .wait()
Jeremy
March 1, 2021 at 9:22 pm #6680adamliter
ParticipantThanks for this suggestion, Jeremy! I had forgotten about the
callback
method. However, after trying this, all of my recordings now seem to be empty. The zip files are saved to my server, but when I unzip them I get the following error (using the command line utilityunzip
on macOS:warning [uploads/ef29bba9-9e2c-3325-5b27-5ee7bff1179a.zip]: zipfile is empty
Any idea why that might be the case?March 2, 2021 at 12:25 am #6681Jeremy
KeymasterI’m not sure why, but I realize that the
once
command there is superfluous, so maybe try removing it to see if that fixes the problem. Also try adding a 200ms Timer element (don’t forget tostart
andwait
for it) before the closing parenthesis of thenewTrial
so as to give time to your trial to process the stopping of the MediaRecorder elementMarch 2, 2021 at 12:16 pm #6682adamliter
ParticipantThanks, Jeremy. Removing the superfluous
once
did not fix the issue, but adding a Timer element did. As always, thank you so much for your help. I really appreciate it! -
AuthorPosts
- You must be logged in to reply to this topic.