diff --git a/static/main.js b/static/main.js index bfe0db3..f878edc 100644 --- a/static/main.js +++ b/static/main.js @@ -36,7 +36,9 @@ function moveBar(e, bar, vid) { vid.currentTime = prog * vid.duration; } -function prog(vid, bar) { +function prog(vid, bar, play) { + play.querySelector('img').src = vid.paused ? '/static/img/play.svg' : '/static/img/stop.svg'; + bar.querySelector('div').style.width = `${vid.currentTime / vid.duration * 100}%`; } @@ -48,8 +50,6 @@ function controls(vid) { let h = document.querySelector('.header'); video.onclick = play.onclick = () => { - play.querySelector('img').src = !video.paused ? '/static/img/play.svg' : '/static/img/stop.svg'; - if (video.paused) { video.play(); return; @@ -71,7 +71,7 @@ function controls(vid) { bar.onclick = (e) => moveBar(e, bar, video); - video.addEventListener('timeupdate', () => prog(video,bar)); + video.addEventListener('timeupdate', () => prog(video, bar, play)); } window.onload = function () {