Skip to content

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

fix(api): mute instead of toggle when muteRemoteParticipant targets the local participant

7Prabhat119849148e72
diff --git a/modules/API/API.js b/modules/API/API.js
index effdd7cf1a..15472e7e60 100755
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -259,13 +259,14 @@ function initCommands() {
const muteMediaType = mediaType ? mediaType : MEDIA_TYPE.AUDIO;
const localParticipant = getLocalParticipant(state);
- // Check if targeting the local participant
+ // Check if targeting the local participant. Always mute here, never toggle, so that
+ // repeating the command on an already muted local participant does not unmute them.
if (participantId === localParticipant?.id) {
if (muteMediaType === MEDIA_TYPE.AUDIO) {
- APP.conference.toggleAudioMuted(false);
+ APP.conference.muteAudio(true);
} else if (muteMediaType === MEDIA_TYPE.VIDEO) {
- APP.conference.toggleVideoMuted(false, true);
+ APP.conference.muteVideo(true);
}
return;
diff --git a/tests/pageobjects/IframeAPI.ts b/tests/pageobjects/IframeAPI.ts
index a8a0c83878..7527d39275 100644
--- a/tests/pageobjects/IframeAPI.ts
+++ b/tests/pageobjects/IframeAPI.ts
@@ -110,6 +110,20 @@ export default class IframeAPI extends BasePageObject {
return this.participant.execute(() => window.jitsiAPI.isLobbyEnabled());
}
+ /**
+ * Returns whether the local participant's audio is muted.
+ */
+ isAudioMuted() {
+ return this.participant.execute(() => window.jitsiAPI.isAudioMuted());
+ }
+
+ /**
+ * Returns whether the local participant's video is muted.
+ */
+ isVideoMuted() {
+ return this.participant.execute(() => window.jitsiAPI.isVideoMuted());
+ }
+
/**
* Removes the embedded Jitsi Meet conference.
*/
diff --git a/tests/specs/iframe/muteSelf.spec.ts b/tests/specs/iframe/muteSelf.spec.ts
new file mode 100644
index 0000000000..810ba50511
--- /dev/null
+++ b/tests/specs/iframe/muteSelf.spec.ts
@@ -0,0 +1,84 @@
+import { expect } from '@wdio/globals';
+
+import type { Participant } from '../../helpers/Participant';
+import { setTestProperties } from '../../helpers/TestProperties';
+import { joinMuc } from '../../helpers/joinMuc';
+
+import { checkIframeApi } from './util';
+
+setTestProperties(__filename, {
+ usesBrowsers: [ 'p1' ]
+});
+
+describe('muteRemoteParticipant iframe API command on the local participant', () => {
+ let p1: Participant;
+
+ it('setup', async () => {
+ p1 = await joinMuc({ name: 'p1', iFrameApi: true });
+
+ if (!await checkIframeApi(p1)) {
+ return;
+ }
+
+ await p1.switchToMainFrame();
+
+ await p1.getIframeAPI().addEventListener('audioMuteStatusChanged');
+ await p1.getIframeAPI().addEventListener('videoMuteStatusChanged');
+ });
+
+ it('mutes local audio and keeps it muted when repeated', async () => {
+ const iframeAPI = p1.getIframeAPI();
+ const p1EndpointId = await p1.getEndpointId();
+
+ await iframeAPI.clearEventResults('audioMuteStatusChanged');
+ await iframeAPI.executeCommand('muteRemoteParticipant', p1EndpointId, 'audio');
+
+ const mutedEvent: { muted: boolean; } = await p1.driver.waitUntil(
+ () => iframeAPI.getEventResult('audioMuteStatusChanged'),
+ {
+ timeout: 5000,
+ timeoutMsg: 'audioMuteStatusChanged event was not received after muteRemoteParticipant'
+ }
+ );
+
+ expect(mutedEvent.muted).toBe(true);
+
+ // Muting an already muted local participant must not unmute them.
+ await iframeAPI.clearEventResults('audioMuteStatusChanged');
+ await iframeAPI.executeCommand('muteRemoteParticipant', p1EndpointId, 'audio');
+ await p1.driver.pause(1000);
+
+ const secondEvent = await iframeAPI.getEventResult('audioMuteStatusChanged');
+
+ expect(secondEvent ? secondEvent.muted : true).toBe(true);
+ expect(await iframeAPI.isAudioMuted()).toBe(true);
+ });
+
+ it('mutes local video and keeps it muted when repeated', async () => {
+ const iframeAPI = p1.getIframeAPI();
+ const p1EndpointId = await p1.getEndpointId();
+
+ await iframeAPI.clearEventResults('videoMuteStatusChanged');
+ await iframeAPI.executeCommand('muteRemoteParticipant', p1EndpointId, 'video');
+
+ const mutedEvent: { muted: boolean; } = await p1.driver.waitUntil(
+ () => iframeAPI.getEventResult('videoMuteStatusChanged'),
+ {
+ timeout: 5000,
+ timeoutMsg: 'videoMuteStatusChanged event was not received after muteRemoteParticipant'
+ }
+ );
+
+ expect(mutedEvent.muted).toBe(true);
+
+ // Muting an already muted local participant must not unmute them.
+ await iframeAPI.clearEventResults('videoMuteStatusChanged');
+ await iframeAPI.executeCommand('muteRemoteParticipant', p1EndpointId, 'video');
+ await p1.driver.pause(1000);
+
+ const secondEvent = await iframeAPI.getEventResult('videoMuteStatusChanged');
+
+ expect(secondEvent ? secondEvent.muted : true).toBe(true);
+ expect(await iframeAPI.isVideoMuted()).toBe(true);
+ });
+});