Automatically start recording at end of trial and have a submit button

PennController for IBEX Forums Support Automatically start recording at end of trial and have a submit button

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6673
    adamliter
    Participant

    Is 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 + '"')
     );
    #6679
    Jeremy
    Keymaster

    Hi,

    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

    #6680
    adamliter
    Participant

    Thanks 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 utility unzip on macOS: warning [uploads/ef29bba9-9e2c-3325-5b27-5ee7bff1179a.zip]: zipfile is empty Any idea why that might be the case?

    #6681
    Jeremy
    Keymaster

    I’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 to start and wait for it) before the closing parenthesis of the newTrial so as to give time to your trial to process the stopping of the MediaRecorder element

    #6682
    adamliter
    Participant

    Thanks, 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!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.