From f68303263ff06c02a32eb968c7098310fbdecf20 Mon Sep 17 00:00:00 2001 From: onezDerv Date: Fri, 20 Sep 2024 08:38:33 -0400 Subject: [PATCH] video controls --- static/img/play.svg | 48 +++++++++++++++++++++++++++++++++++++++++++++ static/img/stop.svg | 48 +++++++++++++++++++++++++++++++++++++++++++++ static/main.css | 38 +++++++++++++++++++++++++++++------ static/main.js | 12 ++++++++---- views/player.ejs | 8 +++++--- views/videos.ejs | 15 +++++++------- 6 files changed, 149 insertions(+), 20 deletions(-) create mode 100644 static/img/play.svg create mode 100644 static/img/stop.svg diff --git a/static/img/play.svg b/static/img/play.svg new file mode 100644 index 0000000..4cafd8c --- /dev/null +++ b/static/img/play.svg @@ -0,0 +1,48 @@ + + + + + + + + + + diff --git a/static/img/stop.svg b/static/img/stop.svg new file mode 100644 index 0000000..6289728 --- /dev/null +++ b/static/img/stop.svg @@ -0,0 +1,48 @@ + + + + + + + + + + diff --git a/static/main.css b/static/main.css index 1771256..731370c 100644 --- a/static/main.css +++ b/static/main.css @@ -36,7 +36,8 @@ textarea, .button, .area, form, -.video { +.video, +.controls { border: solid var(--dark-2) 3px; border-radius: 5px; @@ -45,6 +46,11 @@ form, margin-bottom: 0.5rem; } +video { + border: solid var(--dark-2) 3px; + border-radius: 5px; +} + form span { font-weight: bold; } @@ -77,7 +83,7 @@ form { font-style: italic; } -#main-content { +.main-content { width: 720px; } @@ -115,7 +121,8 @@ form { } video { - width: 690px; + width: 900px; + max-width: 90vw; } .video img { @@ -135,6 +142,12 @@ video { justify-content: space-around; } +.controls { + display: flex; + flex-direction: row; + flex-wrap: wrap; +} + .videos a { color: var(--dark-1); } @@ -143,7 +156,7 @@ textarea { display: block; } -#progressbar { +.progressbar { background-color: var(--light-1); border: solid var(--dark-2) 2px; border-radius: 13px; @@ -151,12 +164,25 @@ textarea { margin: 0; position: relative; top: -40px; - width: 680px; + width: 893px; + max-width: 89vw; } -#progressbar>div { +.progressbar>div { background-color: var(--light-2); width: 40%; height: 20px; border-radius: 10px; +} + +.controls { + margin-top: -30px; +} + +.controls img { + width: 45px; +} + +img.dark { + filter: invert(1); } \ No newline at end of file diff --git a/static/main.js b/static/main.js index 88f9a85..3748592 100644 --- a/static/main.js +++ b/static/main.js @@ -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); } } \ No newline at end of file diff --git a/views/player.ejs b/views/player.ejs index 443701e..013ed15 100644 --- a/views/player.ejs +++ b/views/player.ejs @@ -1,11 +1,14 @@ <%- include('header.ejs') -%>

Video

-
+
-
+
+
+
+
<%= videoData.title %> @@ -15,6 +18,5 @@ <%= videoData.username %>
<%= videoData.desc %>
-
<%- include('footer.ejs') -%> \ No newline at end of file diff --git a/views/videos.ejs b/views/videos.ejs index 0f71eee..2fb12e9 100644 --- a/views/videos.ejs +++ b/views/videos.ejs @@ -2,13 +2,14 @@ <% } %> \ No newline at end of file