Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(device-selection): set audio output sink id after receiving ref (#4066)

virtuacoplenny7a677ead93d1
diff --git a/react/features/device-selection/components/AudioOutputPreview.js b/react/features/device-selection/components/AudioOutputPreview.js
index b744477c27..e5cbc954b2 100644
--- a/react/features/device-selection/components/AudioOutputPreview.js
+++ b/react/features/device-selection/components/AudioOutputPreview.js
@@ -42,19 +42,8 @@ class AudioOutputPreview extends Component<Props> {
this._audioElement = null;
+ this._audioElementReady = this._audioElementReady.bind(this);
this._onClick = this._onClick.bind(this);
- this._setAudioElement = this._setAudioElement.bind(this);
- }
-
- /**
- * Sets the target output device on the component's audio element after
- * initial render.
- *
- * @inheritdoc
- * @returns {void}
- */
- componentDidMount() {
- this._setAudioSink();
}
/**
@@ -81,37 +70,39 @@ class AudioOutputPreview extends Component<Props> {
{ this.props.t('deviceSelection.testAudio') }
</a>
<Audio
- setRef = { this._setAudioElement }
+ setRef = { this._audioElementReady }
src = { TEST_SOUND_PATH } />
</div>
);
}
- _onClick: () => void;
+ _audioElementReady: (Object) => void;
/**
- * Plays a test sound.
+ * Sets the instance variable for the component's audio element so it can be
+ * accessed directly.
*
+ * @param {Object} element - The DOM element for the component's audio.
* @private
* @returns {void}
*/
- _onClick() {
- this._audioElement
- && this._audioElement.play();
+ _audioElementReady(element: Object) {
+ this._audioElement = element;
+
+ this._setAudioSink();
}
- _setAudioElement: (Object) => void;
+ _onClick: () => void;
/**
- * Sets the instance variable for the component's audio element so it can be
- * accessed directly.
+ * Plays a test sound.
*
- * @param {Object} element - The DOM element for the component's audio.
* @private
* @returns {void}
*/
- _setAudioElement(element: Object) {
- this._audioElement = element;
+ _onClick() {
+ this._audioElement
+ && this._audioElement.play();
}
/**
@@ -122,7 +113,7 @@ class AudioOutputPreview extends Component<Props> {
*/
_setAudioSink() {
this._audioElement
- && this._audioElement.setSinkId(this.props.deviceId);
+ && this._audioElement.setSinkId(this.props.deviceId);
}
}