+ audio.addEventListener('timeupdate', updateTime);
+ audio.addEventListener('durationchange', eventLogger);
+ audio.addEventListener('durationchange', updateDuration);
+ }
+
+ function formatTime(time) {
+ var seconds = (time % 60).toFixed(0);
+ var minutes = (time / 60).toFixed(0);
+ return ("0" + minutes).substr(-2, 2) + ':' + ("0" + seconds).substr(-2, 2);
+ }
+
+ function updateTime() {
+ var time = document.getElementById('time');
+ time.innerText = formatTime(audio.currentTime);
+ }
+
+ function updateDuration() {
+ var duration = document.getElementById('duration');
+ duration.innerText = formatTime(audio.duration);