[vlc-devel] [PATCH] web interface: add keyboard shortcuts to control the input buttons

Marko Mohsen xmarcoied at gmail.com
Sat Apr 15 14:16:18 CEST 2017


I modified the ui.js to enable controlling some buttons in the web interfaces by keyboard.
I implemented the "Play button" by the space-bar , the "NextButton" by the right-arrow and the "PrevButton" by the left-arrow

share/lua/http/js/ui.js | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/share/lua/http/js/ui.js b/share/lua/http/js/ui.js
index a404ef0..4eaadad 100644
--- a/share/lua/http/js/ui.js
+++ b/share/lua/http/js/ui.js
@@ -57,7 +57,49 @@ $(function () {
         }
         return false;
     });
-    $('#buttonPlay').click(function () {
+
+    $(window).keydown(function(e) {
+        switch(e.keyCode){
+            case 32:
+                // ButtonPlay -> Space bar character
+                if($('#buttonPlay').attr('state')=='stopped') {
+                    switch (current_que) {
+                    case 'main':
+                        var id = $('.jstree-clicked', '#libraryTree').length > 0 ? $('.jstree-clicked', '#libraryTree').first().parents().first().attr('id').substr(5) : current_id;
+                        sendCommand({
+                            'command': 'pl_play',
+                            'id': id
+                        });
+                        break;
+                    case 'stream':
+                        sendVLMCmd('control Current play');
+                        flowplayer("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.7.swf");
+                        break;
+                    }
+                } else {
+                    switch (current_que) {
+                    case 'main':
+                        sendCommand({
+                            'command': 'pl_pause'
+                        });
+                        break;
+                    case 'stream':
+                        sendVLMCmd('control Current pause');
+                        break;
+                    }
+                }
+                break
+            case 39:
+                // buttonNext -> ArrowRight
+                sendCommand({'command':'pl_next'});
+                break
+            case 37:
+                // buttonPrev -> ArrowLeft
+                sendCommand({'command':'pl_previous'});
+                break
+        }
+    });
+    $('#buttonPlay').click(function () {
         if ($(this).attr('state') == 'stopped') {
             switch (current_que) {
             case 'main':
--
2.9.3


More information about the vlc-devel mailing list