video controls
This commit is contained in:
parent
b9a4c8c18c
commit
3109c791f1
6 changed files with 149 additions and 20 deletions
|
@ -22,7 +22,7 @@ async function formClick(ev) {
|
|||
function moveBar(e, bar, vid) {
|
||||
let rect = bar.getBoundingClientRect();
|
||||
let prog = ((e.pageX - rect.x) / rect.width);
|
||||
|
||||
|
||||
vid.currentTime = prog * vid.duration;
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,14 @@ function prog(vid, bar) {
|
|||
}
|
||||
|
||||
function controls(vid) {
|
||||
let bar = vid.querySelector('#progressbar');
|
||||
let bar = vid.querySelector('.progressbar');
|
||||
let video = vid.querySelector('video');
|
||||
let play = vid.querySelector('.play');
|
||||
|
||||
video.onclick = play.onclick = () => {
|
||||
|
||||
play.querySelector('img').src = !video.paused ? '/static/img/play.svg' : '/static/img/stop.svg';
|
||||
|
||||
video.onclick = () => {
|
||||
if (video.paused) {
|
||||
video.play();
|
||||
return;
|
||||
|
@ -49,7 +53,7 @@ function controls(vid) {
|
|||
|
||||
window.onload = function () {
|
||||
document.addEventListener('submit', formClick);
|
||||
for (let vid of document.querySelectorAll('#video')) {
|
||||
for (let vid of document.querySelectorAll('.video-wrapper')) {
|
||||
controls(vid);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue