mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
add parameter to store audio url; release it if not stored
This commit is contained in:
parent
ffd7e1e45a
commit
0cc69e0854
@ -29,6 +29,10 @@ const info = <const>{
|
|||||||
type: ParameterType.BOOL,
|
type: ParameterType.BOOL,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
store_audio_url: {
|
||||||
|
type: ParameterType.BOOL,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -165,7 +169,11 @@ class HtmlAudioResponsePlugin implements JsPsychPlugin<Info> {
|
|||||||
<button id="continue" class="jspsych-btn">Continue</button>
|
<button id="continue" class="jspsych-btn">Continue</button>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
display_element.querySelector("#record-again").addEventListener("click", this.startRecording);
|
display_element.querySelector("#record-again").addEventListener("click", () => {
|
||||||
|
// release object url to save memory
|
||||||
|
URL.revokeObjectURL(this.audio_url);
|
||||||
|
this.startRecording();
|
||||||
|
});
|
||||||
display_element.querySelector("#continue").addEventListener("click", () => {
|
display_element.querySelector("#continue").addEventListener("click", () => {
|
||||||
this.endTrial(display_element, trial);
|
this.endTrial(display_element, trial);
|
||||||
});
|
});
|
||||||
@ -179,13 +187,19 @@ class HtmlAudioResponsePlugin implements JsPsychPlugin<Info> {
|
|||||||
this.jsPsych.pluginAPI.clearAllTimeouts();
|
this.jsPsych.pluginAPI.clearAllTimeouts();
|
||||||
|
|
||||||
// gather the data to store for the trial
|
// gather the data to store for the trial
|
||||||
var trial_data = {
|
var trial_data: any = {
|
||||||
rt: this.rt,
|
rt: this.rt,
|
||||||
stimulus: trial.stimulus,
|
stimulus: trial.stimulus,
|
||||||
response: this.response,
|
response: this.response,
|
||||||
estimated_stimulus_onset: Math.round(this.stimulus_start_time - this.recorder_start_time),
|
estimated_stimulus_onset: Math.round(this.stimulus_start_time - this.recorder_start_time),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (trial.store_audio_url) {
|
||||||
|
trial_data.audio_url = this.audio_url;
|
||||||
|
} else {
|
||||||
|
URL.revokeObjectURL(this.audio_url);
|
||||||
|
}
|
||||||
|
|
||||||
// clear the display
|
// clear the display
|
||||||
display_element.innerHTML = "";
|
display_element.innerHTML = "";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user