X-Git-Url: http://105106.c2e0p.group/sound.git/blobdiff_plain/82e3a8a15e29c81d92cdb6432d9dad531c03063a..HEAD:/sound.html diff --git a/sound.html b/sound.html index d5185e4..af92487 100644 --- a/sound.html +++ b/sound.html @@ -32,8 +32,10 @@ audio.addEventListener('canplaythrough', eventLogger); audio.addEventListener('emptied', eventLogger); audio.addEventListener('ended', eventLogger); + audio.addEventListener('ended', updateTime); audio.addEventListener('loadstart', eventLogger); audio.addEventListener('pause', eventLogger); + audio.addEventListener('pause', updateTime); audio.addEventListener('play', eventLogger); audio.addEventListener('playing', eventLogger); audio.addEventListener('progress', eventLogger); @@ -44,6 +46,8 @@ audio.addEventListener('timeupdate', updateTime); audio.addEventListener('durationchange', eventLogger); audio.addEventListener('durationchange', updateDuration); + audio.addEventListener('ratechange', eventLogger); + audio.addEventListener('ratechange', updateRate); } function formatTime(time) { @@ -54,12 +58,24 @@ function updateTime() { var time = document.getElementById('time'); - time.innerText = formatTime(audio.currentTime); + var currentTime = audio.currentTime; + time.innerText = formatTime(currentTime); + + var timeline = document.getElementById('timeline'); + timeline.value = currentTime; } function updateDuration() { var duration = document.getElementById('duration'); duration.innerText = formatTime(audio.duration); + + var timeline = document.getElementById('timeline'); + timeline.max = audio.duration; + } + + function updateRate() { + var rate = document.getElementById('rate'); + rate.value = audio.playbackRate; } @@ -72,13 +88,16 @@