From 19872ae4acd1af7dded5112ef1cb39671f5d89ee Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Mar 2018 13:23:10 +0100 Subject: [PATCH] Add shortcuts for calling a - toggle audio on/off v - toggle video on/off p - switch to participants tab c - switch to chat tab Signed-off-by: Joas Schilling --- js/app.js | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/js/app.js b/js/app.js index 42882cb1881..0d97560f90f 100644 --- a/js/app.js +++ b/js/app.js @@ -319,7 +319,50 @@ OCA.SpreedMe.webrtc.stopScreenShare(); screensharingStopped(); }); + + $(document).keyup(this._onKeyUp.bind(this)); }, + + _onKeyUp: function(event) { + // Define which objects to check for the event properties. + var key = event.which; + + // Trigger the event only if no input or textarea is focused + // and the CTRL key is not pressed + if ($('input:focus').length === 0 && + $('textarea:focus').length === 0 && + !event.ctrlKey) { + + // Actual shortcut handling + switch (key) { + case 86: // 'v' + event.preventDefault(); + if (this.videoDisabled) { + this.enableVideo(); + } else { + this.disableVideo(); + } + break; + case 65: // 'a' + event.preventDefault(); + if (this.audioDisabled) { + this.enableAudio(); + } else { + this.disableAudio(); + } + break; + case 67: // 'c' + event.preventDefault(); + this._sidebarView.selectTab('chat'); + break; + case 80: // 'p' + event.preventDefault(); + this._sidebarView.selectTab('participants'); + break; + } + } + }, + _showRoomList: function() { this._roomsView = new OCA.SpreedMe.Views.RoomListView({ el: '#app-navigation ul', @@ -609,6 +652,10 @@ } }, enableAudio: function() { + if (!OCA.SpreedMe.webrtc) { + return; + } + OCA.SpreedMe.webrtc.unmute(); $('#mute').attr('data-original-title', t('spreed', 'Mute audio')) .removeClass('audio-disabled icon-audio-off') @@ -617,6 +664,10 @@ OCA.SpreedMe.app.audioDisabled = false; }, disableAudio: function() { + if (!OCA.SpreedMe.webrtc) { + return; + } + OCA.SpreedMe.webrtc.mute(); $('#mute').attr('data-original-title', t('spreed', 'Enable audio')) .addClass('audio-disabled icon-audio-off') @@ -625,6 +676,10 @@ OCA.SpreedMe.app.audioDisabled = true; }, enableVideo: function() { + if (!OCA.SpreedMe.webrtc) { + return; + } + var $hideVideoButton = $('#hideVideo'); var $audioMuteButton = $('#mute'); var avatarContainer = $hideVideoButton.closest('.videoView').find('.avatar-container'); @@ -642,6 +697,10 @@ OCA.SpreedMe.app.videoDisabled = false; }, hideVideo: function() { + if (!OCA.SpreedMe.webrtc) { + return; + } + var $hideVideoButton = $('#hideVideo'); var $audioMuteButton = $('#mute'); var avatarContainer = $hideVideoButton.closest('.videoView').find('.avatar-container');