fix playbar

This commit is contained in:
biglyderv 2024-11-25 14:12:44 -05:00
parent d4ed9e48cf
commit ca6b399dce

View file

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