利用 HTML5 的 audio 元件測得 audio 檔案的秒數
var audio = document.createElement("audio"); document.querySelector("input").addEventListener( "change", function( event ){ var file = event.target.files[0]; var fileURL = URL.createObjectURL(file); audio.addEventListener("loadedmetadata", function(){ alert( audio.duration + " sec" ); }); audio.src = fileURL; });