소스 검색

Restore the audio and video mute/unmute keyboard shortcuts

I don't think it's realistic that we'd merge a PR that breaks the most
important shortcuts of the app (in my opinion): audio and video
mute/unmute.
master
Lyubo Marinov 7 년 전
부모
커밋
f1123a8cdd
2개의 변경된 파일124개의 추가작업 그리고 0개의 파일을 삭제
  1. 62
    0
      react/features/toolbox/components/AudioMuteButton.js
  2. 62
    0
      react/features/toolbox/components/VideoMuteButton.js

+ 62
- 0
react/features/toolbox/components/AudioMuteButton.js 파일 보기

3
 import { connect } from 'react-redux';
3
 import { connect } from 'react-redux';
4
 
4
 
5
 import {
5
 import {
6
+    ACTION_SHORTCUT_TRIGGERED,
6
     AUDIO_MUTE,
7
     AUDIO_MUTE,
8
+    createShortcutEvent,
7
     createToolbarEvent,
9
     createToolbarEvent,
8
     sendAnalytics
10
     sendAnalytics
9
 } from '../../analytics';
11
 } from '../../analytics';
13
 import type { AbstractButtonProps } from '../../base/toolbox';
15
 import type { AbstractButtonProps } from '../../base/toolbox';
14
 import { isLocalTrackMuted } from '../../base/tracks';
16
 import { isLocalTrackMuted } from '../../base/tracks';
15
 
17
 
18
+declare var APP: Object;
19
+
16
 /**
20
 /**
17
  * The type of the React {@code Component} props of {@link AudioMuteButton}.
21
  * The type of the React {@code Component} props of {@link AudioMuteButton}.
18
  */
22
  */
38
     label = 'toolbar.mute';
42
     label = 'toolbar.mute';
39
     tooltip = 'toolbar.mute';
43
     tooltip = 'toolbar.mute';
40
 
44
 
45
+    /**
46
+     * Initializes a new {@code AudioMuteButton} instance.
47
+     *
48
+     * @param {Props} props - The read-only React {@code Component} props with
49
+     * which the new instance is to be initialized.
50
+     */
51
+    constructor(props: Props) {
52
+        super(props);
53
+
54
+        // Bind event handlers so they are only bound once per instance.
55
+        this._onKeyboardShortcut = this._onKeyboardShortcut.bind(this);
56
+    }
57
+
58
+    /**
59
+     * Registers the keyboard shortcut that toggles the audio muting.
60
+     *
61
+     * @inheritdoc
62
+     * @returns {void}
63
+     */
64
+    componentDidMount() {
65
+        typeof APP === 'undefined'
66
+            || APP.keyboardshortcut.registerShortcut(
67
+                'M',
68
+                null,
69
+                this._onKeyboardShortcut,
70
+                'keyboardShortcuts.mute');
71
+    }
72
+
73
+    /**
74
+     * Unregisters the keyboard shortcut that toggles the audio muting.
75
+     *
76
+     * @inheritdoc
77
+     * @returns {void}
78
+     */
79
+    componentWillUnmount() {
80
+        typeof APP === 'undefined'
81
+            || APP.keyboardshortcut.unregisterShortcut('M');
82
+    }
83
+
41
     /**
84
     /**
42
      * Indicates if audio is currently muted ot nor.
85
      * Indicates if audio is currently muted ot nor.
43
      *
86
      *
49
         return this.props._audioMuted;
92
         return this.props._audioMuted;
50
     }
93
     }
51
 
94
 
95
+    _onKeyboardShortcut: () => void;
96
+
97
+    /**
98
+     * Creates an analytics keyboard shortcut event and dispatches an action to
99
+     * toggle the audio muting.
100
+     *
101
+     * @private
102
+     * @returns {void}
103
+     */
104
+    _onKeyboardShortcut() {
105
+        sendAnalytics(
106
+            createShortcutEvent(
107
+                AUDIO_MUTE,
108
+                ACTION_SHORTCUT_TRIGGERED,
109
+                { enable: !this._isAudioMuted() }));
110
+
111
+        super._handleClick();
112
+    }
113
+
52
     /**
114
     /**
53
      * Changes the muted state.
115
      * Changes the muted state.
54
      *
116
      *

+ 62
- 0
react/features/toolbox/components/VideoMuteButton.js 파일 보기

3
 import { connect } from 'react-redux';
3
 import { connect } from 'react-redux';
4
 
4
 
5
 import {
5
 import {
6
+    ACTION_SHORTCUT_TRIGGERED,
6
     VIDEO_MUTE,
7
     VIDEO_MUTE,
8
+    createShortcutEvent,
7
     createToolbarEvent,
9
     createToolbarEvent,
8
     sendAnalytics
10
     sendAnalytics
9
 } from '../../analytics';
11
 } from '../../analytics';
17
 import type { AbstractButtonProps } from '../../base/toolbox';
19
 import type { AbstractButtonProps } from '../../base/toolbox';
18
 import { isLocalTrackMuted } from '../../base/tracks';
20
 import { isLocalTrackMuted } from '../../base/tracks';
19
 
21
 
22
+declare var APP: Object;
23
+
20
 /**
24
 /**
21
  * The type of the React {@code Component} props of {@link VideoMuteButton}.
25
  * The type of the React {@code Component} props of {@link VideoMuteButton}.
22
  */
26
  */
47
     label = 'toolbar.videomute';
51
     label = 'toolbar.videomute';
48
     tooltip = 'toolbar.videomute';
52
     tooltip = 'toolbar.videomute';
49
 
53
 
54
+    /**
55
+     * Initializes a new {@code VideoMuteButton} instance.
56
+     *
57
+     * @param {Props} props - The read-only React {@code Component} props with
58
+     * which the new instance is to be initialized.
59
+     */
60
+    constructor(props: Props) {
61
+        super(props);
62
+
63
+        // Bind event handlers so they are only bound once per instance.
64
+        this._onKeyboardShortcut = this._onKeyboardShortcut.bind(this);
65
+    }
66
+
67
+    /**
68
+     * Registers the keyboard shortcut that toggles the video muting.
69
+     *
70
+     * @inheritdoc
71
+     * @returns {void}
72
+     */
73
+    componentDidMount() {
74
+        typeof APP === 'undefined'
75
+            || APP.keyboardshortcut.registerShortcut(
76
+                'V',
77
+                null,
78
+                this._onKeyboardShortcut,
79
+                'keyboardShortcuts.videoMute');
80
+    }
81
+
82
+    /**
83
+     * Unregisters the keyboard shortcut that toggles the video muting.
84
+     *
85
+     * @inheritdoc
86
+     * @returns {void}
87
+     */
88
+    componentWillUnmount() {
89
+        typeof APP === 'undefined'
90
+            || APP.keyboardshortcut.unregisterShortcut('V');
91
+    }
92
+
50
     /**
93
     /**
51
      * Indicates if this button should be disabled or not.
94
      * Indicates if this button should be disabled or not.
52
      *
95
      *
69
         return this.props._videoMuted;
112
         return this.props._videoMuted;
70
     }
113
     }
71
 
114
 
115
+    _onKeyboardShortcut: () => void;
116
+
117
+    /**
118
+     * Creates an analytics keyboard shortcut event and dispatches an action to
119
+     * toggle the video muting.
120
+     *
121
+     * @private
122
+     * @returns {void}
123
+     */
124
+    _onKeyboardShortcut() {
125
+        sendAnalytics(
126
+            createShortcutEvent(
127
+                VIDEO_MUTE,
128
+                ACTION_SHORTCUT_TRIGGERED,
129
+                { enable: !this._isVideoMuted() }));
130
+
131
+        super._handleClick();
132
+    }
133
+
72
     /**
134
     /**
73
      * Changes the muted state.
135
      * Changes the muted state.
74
      *
136
      *

Loading…
취소
저장