PennController for IBEX › Forums › Support › MediaRecorder – filenames using ID › Reply To: MediaRecorder – filenames using ID
Hi Jeremy,
I was trying to store a unique participantID in the audio filename as well.
I created a javascript variable and referred to it in the newMediaRecorder name, but I always get errors – either “[12:25:57] Uncaught SyntaxError: Unexpected token ‘variable’ (newTrial: 0), or an “ERROR: Wrong number of arguments (or bad argument) to SepWith” (even if I’m not touching the sepWith trials).
I’m quite sure there is something wrong in the way I refer to the variable in the newMediaRecorder name. But I cannot figure out how to fix it. Could you help me out?
Here’s the trial with the function to define the variable
// Set unique participant ID to better recognize audios
newTrial("speakID",
newVar("speakID")
.settings.global()
.set(v =>[...Array(4)].reduce(a=>a+alphanum.charAt(Math.floor(Math.random()*alphanum.length)),''))
,
newText("speakID", "")
.settings.text(getVar("speakID"))
.print(),
newButton().print().wait() // to be deleted, just to double check that the code matches the audiofile
)
.log("speakID", getVar("speakID"))
And here’s the way I named my newMediaRecorder element in following trials
newMediaRecorder(row.itemID+"_"+row.modality+"_"+variable.speakID, "audio")
If I don’t refer to the variable in the audiofile name, everything goes smoothly.
Thank you in advance!
Dod