浏览代码

tuner HW done

vladislavaSim 1 年之前
父节点
当前提交
fdafc2a788
共有 2 个文件被更改,包括 17 次插入11 次删除
  1. 10 3
      tuner/index.html
  2. 7 8
      tuner/index.js

+ 10 - 3
tuner/index.html

@@ -5,9 +5,9 @@
     <title>Tuner</title>
     <style>
         #container1 {
-            padding: 400px;
+            padding: 40px;
         }
-        #container2 > img{
+        img{
             width: 100px;
             height: 100px;
             margin: 15px;
@@ -20,10 +20,17 @@
     </style>
 </head>
 <body>
-<div id='container1'></div>
 <div id='container2'></div>
 
 <div id="colorBox"></div>
+<div class="audioBox">
+    <div id='container1'></div>
+    <p>bbno$ ft Diamond Pistols - Help Yourself</p>
+    <audio class="mySong" autoplay controls>
+        <source src="bbno$%20x%20diamond%20pistols%20%20help%20herself.mp3" type="audio/mp3">
+        Your browser does not support the audio element.
+    </audio>
+</div>
 <script src='index.js'></script>
 </body>
 </html>

+ 7 - 8
tuner/index.js

@@ -53,13 +53,13 @@ function Control(el, {value=50,
 
     this.setValue(value)
 }
-
-
-
+let $song = document.querySelector('.mySong')
 const volumeControl  = new Control(container1, {value: 75, minAngle: -180})
-volumeControl.onchange = (value => console.log('ON CHANGE', value)) //на каждый setValue
-//console.log(volumeControl.getValue())
-//пришейте к нему тэг audio для громкости
+volumeControl.onchange = (value => {
+    $song.volume = value / 100
+})
+
+setTimeout(() => volumeControl.setValue(80), 2000)
 
 function setRGB(value, n){
     let arr = ['rgb', '(', red.getValue(), ', ', green.getValue(), ', ', blue.getValue(), ')']
@@ -67,7 +67,6 @@ function setRGB(value, n){
     colorBox.style.backgroundColor = arr.join('')
 }
 
-
 const red  = new Control(container2, {min: 0, max: 255})
 red.onchange = (value) => setRGB(value,0)
 const green  = new Control(container2, {min: 0, max: 255})
@@ -75,4 +74,4 @@ green.onchange = (value) => setRGB(value,1)
 const blue  = new Control(container2, {min: 0, max: 255})
 blue.onchange = (value) => setRGB(value,2)
 
-//setTimeout(() => volumeControl.setValue(80), 2000)
+