From 426fd2bf9670827fd568dbf9bec05f128d1fec32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Z=C3=A1le=C5=A1=C3=A1k?= Date: Sun, 31 Jan 2021 02:52:29 +0100 Subject: [PATCH] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20ovl=C3=A1d=C3=A1n?= =?UTF-8?q?=C3=AD=20hlasitosi=20closes=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/style.css | 60 ++++++++++++++++++++++++++++++++++++++++++++++-- index.php | 9 +++++++- js/controller.js | 3 +++ js/video.js | 11 +++++++++ 4 files changed, 80 insertions(+), 3 deletions(-) diff --git a/css/style.css b/css/style.css index 89968d7..73fdd9d 100644 --- a/css/style.css +++ b/css/style.css @@ -51,10 +51,10 @@ article img { max-width: 25vh; max-height: 100%; margin: 0.5em 1em; - padding: .2em; + padding: 0.2em; clear: both; border: 1px solid #bbb; - border-radius: .2rem; + border-radius: 0.2rem; float: left; clear: left; } @@ -245,3 +245,59 @@ progress::-webkit-progress-bar { margin-left: min(-14px, -0.5vh); cursor: pointer; } +#video-volume { + position: absolute; + left: -7.5vh; + bottom: -0.5em; + margin-left: 1.5em; + margin-bottom: 7.5vh; + width: 15vh; + height: 1em; + -webkit-transform: rotate(-90deg); +} + +#volume { + position: absolute; + left: 1em; + z-index: 20; + width: 100%; + height: 100%; + margin: 0; + appearance: none; + background: transparent; + cursor: pointer; +} + +#volume::-moz-range-thumb { + height: 100%; + width: 0; + appearance: none; + border: none; + border-radius: 0; +} + +#volume::-webkit-slider-thumb { + height: 100%; + width: 0; + appearance: none; + border: none; + border-radius: 0; +} + +#volume-bar { + position: absolute; + left: 1em; + background-color: #616161; + width: 100%; + height: 100%; + z-index: 10; +} + +#volume-bar-value { + position: absolute; + bottom: 0; + background-color: #ffa800; + width: 100%; + height: 100%; + z-index: 15; +} diff --git a/index.php b/index.php index b9e8084..b0669ed 100644 --- a/index.php +++ b/index.php @@ -34,10 +34,17 @@ + +
+
+
+
+ +
- +
diff --git a/js/controller.js b/js/controller.js index 029b431..9e1b49f 100644 --- a/js/controller.js +++ b/js/controller.js @@ -70,6 +70,9 @@ class Controller { }.bind(this) ); + const volume = document.getElementById("volume"); + volume.addEventListener("input", this.view.videoPlayer.updateVolume); + document.addEventListener( "keyup", function (e) { diff --git a/js/video.js b/js/video.js index a38307d..818c517 100644 --- a/js/video.js +++ b/js/video.js @@ -46,6 +46,17 @@ class VideoPlayer { console.log("here"); } } + updateVolume() { + const volume = document.getElementById("volume"); + const volumeBar = document.getElementById("volume-bar-value"); + + if (video.muted) { + video.muted = false; + } + + video.volume = volume.value / 100; + volumeBar.style.width = volume.value + "%"; + } // Play pause togglePlay() { if (this.video.paused || this.video.ended) {