[vlc-devel] [PATCH v3 08/10] http lua: Update to match updated equalizer support in Lua backend

Ronald Wright logiconcepts819 at gmail.com
Sun Nov 29 23:09:40 CET 2015


Note:  This patch cannot be applied without patch 7, which depends on patches 1
and 2.  Patches 5 through 10 must be applied all together.
---
 share/lua/http/css/main.css                  | 17 ++++++++
 share/lua/http/dialogs/equalizer_window.html |  3 ++
 share/lua/http/js/controllers.js             | 59 +++++++++++++++++++++++++---
 share/lua/http/mobile_equalizer.html         |  3 ++
 share/lua/intf/modules/httprequests.lua      |  1 +
 5 files changed, 77 insertions(+), 6 deletions(-)

diff --git a/share/lua/http/css/main.css b/share/lua/http/css/main.css
index aebe6ce..5d52c2a 100644
--- a/share/lua/http/css/main.css
+++ b/share/lua/http/css/main.css
@@ -227,6 +227,18 @@ body{
 	font-size: 11px;
 }
 
+.eqtable{
+	display:table;
+}
+
+.eqrow{
+	display:table-row;
+}
+
+.eqcell{
+	display:table-cell;
+}
+
 #window_equalizer div div{
 	text-align: center;
 	font-size: 11px;
@@ -237,6 +249,11 @@ body{
 	height:80px !important ;
 }
 
+#window_equalizer_controls {
+	overflow-x: auto;
+	white-space: nowrap;
+}
+
 .eqBand{
 	margin-bottom: 10px;
 	margin-top: 10px;
diff --git a/share/lua/http/dialogs/equalizer_window.html b/share/lua/http/dialogs/equalizer_window.html
index a81bb13..edc9d1d 100755
--- a/share/lua/http/dialogs/equalizer_window.html
+++ b/share/lua/http/dialogs/equalizer_window.html
@@ -51,4 +51,7 @@
 	<div style="margin: 5px 5px 10px 5px;">
 		<div id="preamp" style="font-size: 18px;"></div>
 	</div>
+	<div style="margin: 5px 5px 5px 5px;">
+		<div id="window_equalizer_controls"><div class="eqtable"><div id="window_equalizer_control_row" class="eqrow"></div></div></div>
+	</div>
 </div>
diff --git a/share/lua/http/js/controllers.js b/share/lua/http/js/controllers.js
index 8c3a419..853ec93 100644
--- a/share/lua/http/js/controllers.js
+++ b/share/lua/http/js/controllers.js
@@ -9,6 +9,35 @@ function updateArt(url) {
     });
 }
 
+function getEqzBandFreqs(bandsCount, vlcFreqs) {
+    var freq;
+    if (bandsCount == 10) {
+        if (vlcFreqs) {
+            freq = ["60 Hz", "170 Hz", "310 Hz", "600 Hz", "1 kHz", "3 kHz",
+                    "6 kHz", "12 kHz", "14 kHz", "16 kHz"];
+        }
+        else {
+            freq = ["31.5 Hz", "63 Hz", "125 Hz", "250 Hz", "500 Hz", "1 kHz",
+                      "2 kHz", "4 kHz",  "8 kHz"," 16 kHz"];
+        }
+    }
+    else if (bandsCount == 15) {
+        freq = [  "25 Hz",  "40 Hz",  "63 Hz",  "100 Hz",  "160 Hz", "250 Hz",
+                 "400 Hz", "630 Hz",  "1 kHz", "1.6 KHz", "2.5 kHz",  "4 kHz",
+                "6.3 kHz", "10 kHz", "16 kHz"];
+    }
+    else if (bandsCount == 31) {
+        freq = [  "20 Hz",   "25 Hz", "31.5 Hz",    "40 Hz",   "50 Hz",
+                  "63 Hz",   "80 Hz",  "100 Hz",   "125 Hz",  "160 Hz",
+                 "200 Hz",  "250 Hz",  "315 Hz",   "400 Hz",  "500 Hz",
+                 "630 Hz",  "800 Hz",   "1 kHz", "1.25 kHz", "1.6 kHz",
+                  "2 kHz", "2.5 kHz", "3.15 Hz",    "4 kHz",   "5 kHz",
+                "6.3 kHz",   "8 kHz",  "10 kHz", "1.25 kHz", "1.6 kHz",
+                 "20 kHz"];
+    }
+    return freq;
+}
+
 function updateStatus() {
     $.ajax({
         url: 'requests/status.xml',
@@ -85,12 +114,21 @@ function updateStatus() {
                 }
 
             }
-            $('band', data).each(function () {
+            var bands = $('band', data);
+            bands.sort(function(a, b) {
+                return $(a).attr('id') - $(b).attr('id');
+            });
+            var vlcfreqs = $('vlcfreqs', data).text() == "true";
+            var freq = getEqzBandFreqs(bands.length, vlcfreqs);
+            var freqdisps = $('#window_equalizer_control_row').children('.eqcell').children('div').children('.eqz_freq_disp');
+            if (bands.length != freqdisps.length || vlcfreqs != (freqdisps.length > 0 && freqdisps.first().text() == "60 Hz")) {
+                $('#window_equalizer_control_row').empty();
+            }
+            bands.each(function () {
                 var id = $(this).attr('id');
                 var value = $(this).text() ? $(this).text() : 0;
-                var freq = ["60 Hz","170 Hz", "310 Hz", "600 Hz", "1 kHz","3 kHz", "6 kHz", "12 kHz" , "14 kHz" , "16 kHz" ];
                 if (!$('#eq_container' + id).length) {
-                    $('#window_equalizer').append('<div style="float:left;width:44px;" align="center" id="eq_container' + id + '"><div id="eq' + id + '_txt">' + value + 'dB</div><div class="eqBand" id="eq' + id + '" style="font-size: 18px;"></div><div>' + freq[id] + '</div></div>');
+                    $('#window_equalizer_control_row').append('<div class="eqcell"><div style="float:left;width:44px;" align="center" id="eq_container' + id + '"><div id="eq' + id + '_txt">' + value + 'dB</div><div class="eqBand" id="eq' + id + '" style="font-size: 18px; display: inline-block;"></div><div class="eqz_freq_disp">' + freq[id] + '</div><div style="height: 10px;"></div></div></div>');
                     $('#eq' + id).slider({
                         min: -20,
                         max: 20,
@@ -382,12 +420,21 @@ function updateEQ() {
     $.ajax({
         url: 'requests/status.xml',
         success: function (data, status, jqXHR) {
-            $('band', data).each(function () {
-                var freq = ["60 Hz","170 Hz", "310 Hz", "600 Hz", "1 kHz","3 kHz", "6 kHz", "12 kHz" , "14 kHz" , "16 kHz" ];
+            var bands = $('band', data);
+            bands.sort(function(a, b) {
+                return $(a).attr('id') - $(b).attr('id');
+            });
+            var vlcfreqs = $('vlcfreqs', data).text() == "true";
+            var freq = getEqzBandFreqs(bands.length, vlcfreqs);
+            var freqdisps = $('#window_equalizer_control_row').children('.eqcell').children('div').children('.eqz_freq_disp');
+            if (bands.length != freqdisps.length || vlcfreqs != (freqdisps.length > 0 && freqdisps.first().text() == "60 Hz")) {
+                $('#window_equalizer_control_row').empty();
+            }
+            bands.each(function () {
                 var id = $(this).attr('id');
                 var value = $(this).text() ? $(this).text() : 0;
                 if (!$('#eq_container' + id).length) {
-                    $('#window_equalizer').append('<div style="float:left;width:44px;" align="center" id="eq_container' + id + '"><div id="eq' + id + '_txt">' + value + 'dB</div><div class="eqBand" id="eq' + id + '" style="font-size: 18px;"></div><div>' + freq[id] + '</div></div>');
+                    $('#window_equalizer_control_row').append('<div class="eqcell"><div style="float:left;width:44px;" align="center" id="eq_container' + id + '"><div id="eq' + id + '_txt">' + value + 'dB</div><div class="eqBand" id="eq' + id + '" style="font-size: 18px; display: inline-block;"></div><div class="eqz_freq_disp">' + freq[id] + '</div><div style="height: 10px;"></div></div></div>');
                     $('#eq' + id).slider({
                         min: -20,
                         max: 20,
diff --git a/share/lua/http/mobile_equalizer.html b/share/lua/http/mobile_equalizer.html
index 7341109..258eb08 100644
--- a/share/lua/http/mobile_equalizer.html
+++ b/share/lua/http/mobile_equalizer.html
@@ -64,6 +64,9 @@
 			<div style="margin: 5px 5px 10px 5px;">
 				<div id="preamp" style="font-size: 22px;"></div>
 			</div>
+			<div style="margin: 5px 5px 5px 5px;">
+				<div id="window_equalizer_controls"><div class="eqtable"><div id="window_equalizer_control_row" class="eqrow"></div></div></div>
+			</div>
 		</div>
 	</body>
 </html>
diff --git a/share/lua/intf/modules/httprequests.lua b/share/lua/intf/modules/httprequests.lua
index e060cc1..1504057 100644
--- a/share/lua/intf/modules/httprequests.lua
+++ b/share/lua/intf/modules/httprequests.lua
@@ -507,6 +507,7 @@ getstatus = function (includecategories)
     s.equalizer={}
     s.equalizer.preamp=round(vlc.equalizer.preampget(),2)
     s.equalizer.bands=vlc.equalizer.equalizerget()
+    s.equalizer.vlcfreqs=vlc.equalizer.usingvlcfreqsget()
     if s.equalizer.bands ~= null then
         for k,i in pairs(s.equalizer.bands) do s.equalizer.bands[k]=round(i,2) end
         s.equalizer.presets=vlc.equalizer.presets()
-- 
1.9.1



More information about the vlc-devel mailing list