|
@@ -3,7 +3,9 @@
|
3
|
3
|
import { connect } from 'react-redux';
|
4
|
4
|
|
5
|
5
|
import {
|
|
6
|
+ ACTION_SHORTCUT_TRIGGERED,
|
6
|
7
|
VIDEO_MUTE,
|
|
8
|
+ createShortcutEvent,
|
7
|
9
|
createToolbarEvent,
|
8
|
10
|
sendAnalytics
|
9
|
11
|
} from '../../analytics';
|
|
@@ -17,6 +19,8 @@ import { AbstractVideoMuteButton } from '../../base/toolbox';
|
17
|
19
|
import type { AbstractButtonProps } from '../../base/toolbox';
|
18
|
20
|
import { isLocalTrackMuted } from '../../base/tracks';
|
19
|
21
|
|
|
22
|
+declare var APP: Object;
|
|
23
|
+
|
20
|
24
|
/**
|
21
|
25
|
* The type of the React {@code Component} props of {@link VideoMuteButton}.
|
22
|
26
|
*/
|
|
@@ -47,6 +51,45 @@ class VideoMuteButton extends AbstractVideoMuteButton<Props, *> {
|
47
|
51
|
label = 'toolbar.videomute';
|
48
|
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
|
94
|
* Indicates if this button should be disabled or not.
|
52
|
95
|
*
|
|
@@ -69,6 +112,25 @@ class VideoMuteButton extends AbstractVideoMuteButton<Props, *> {
|
69
|
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
|
135
|
* Changes the muted state.
|
74
|
136
|
*
|