remove HTML5 stalled event listener & check for progress bar before updating - fixes #1262

This commit is contained in:
Becky Gilbert 2020-12-03 11:01:19 -08:00
parent 6bcb624f7d
commit 7cd7fc65f4

View File

@ -2405,16 +2405,6 @@ jsPsych.pluginAPI = (function() {
}
audio.removeEventListener('error', handleError);
});
audio.addEventListener('stalled', function handleStalled(){
if(count < jsPsych.initSettings().max_preload_attempts){
setTimeout(function(){
load_audio_file_html5audio(source, count+1)
}, 200);
} else {
jsPsych.loadFail();
}
audio.removeEventListener('stalled', handleStalled);
});
audio.addEventListener('abort', function handleAbort(){
if(count < jsPsych.initSettings().max_preload_attempts){
setTimeout(function(){
@ -2618,7 +2608,10 @@ jsPsych.pluginAPI = (function() {
loaded++;
if(progress_bar){
var percent_loaded = (loaded/total_n)*100;
jsPsych.getDisplayElement().querySelector('#jspsych-loading-progress-bar').style.width = percent_loaded+"%";
var preload_progress_bar = jsPsych.getDisplayElement().querySelector('#jspsych-loading-progress-bar');
if (preload_progress_bar !== null) {
preload_progress_bar.style.width = percent_loaded+"%";
}
}
}