我正在使用普通的JavaScript + HTML音频播放器,我想构建一个接口,以MM:SS格式显示音频的当前时间。
document.addEventListener('DOMContentLoaded', function () {
var a = document.getElementById('mytrack');
a.addEventListener("loadedmetadata", function() {
var duration1 = document.getElementById('fullDuration');
duration1.innerHTML = a.duration;
}, true);
}, false);
<audio id="mytrack" controls autoplay>
<source src="https://www57.zippyshare.com/downloadMusic?key=Txf9UxEo&time=" type="audio/mp3" />
</audio>
</br>
<span id="fullDuration">0:00</span>