ok so i did some research and it seemed the best way to determine the length of an audio file with javascript is to create an <audio>
tag, set the file path to the src
attribute, append the child to the DOM, than bind a loadedmetadata
eventListener on the <audio>
tag and use the duration
property of the audio tag to get the length of the audio file. This works great except...
sometimes, and randomly, the loading of the audio file will fail. my code makes the request for the file but it just never receives a response. The tag is still created and appended to the DOM but tag.duration = NaN
.
Is there any other way to determine the length of an audio file with javascript? this is all part of a hack to a Qualtrics survey which is incredibly restrictive so i would like to stick to regular javascript (no jquery) because it is a serious hassle and buggy to try to use jquery with qualtrics.
to make things more annoying, the file that i request is actually a php file with the file name as a query parameter, ex File.php?F=92kls02jf9
. this is how qualtrics does it so don't ask...not sure if this helps or hurts but i figured id add it in.