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) {