Adjust volume levels via javascript

Is it possible to use the iframe method of jitsi meet and then programatically adjust the volume levels of each participant? I’m interested in implementing a simultaneous interpretation solution that allows users to automatically mute everyone except the interpreter (and vice-versa).

Actually I also have similar in mind but not getting time yet.
See if this link helps

Thanks for the tip! A very promising thread.

I have a similar use case and was just about to add that exact functionality. I can open a pull request. I don’t know if it’s gonna be accepted or when, but you can build your own version if you want.

@izakgl Can you share your pull request? Or explain how you did it? I would love to see it.

Here is the pull request: feat(external_api): Control participant volume by izakgl · Pull Request #9322 · jitsi/jitsi-meet · GitHub

Thank you! I will give it a shot.

I’m having trouble cherry picking your commits agains the stable version of jitsi meet that I’m using :(. But I left a supportive comment.

What is the hash of the latest commit you’re using?

I’m running the debian version 1.0.4985-1 which I beleive is based on tag jitsi-meet_4985 (commit: e8c44c10dd0f3cc97870ef75c37dd60b39320c72). I was mostly thrown by the absence of the thumbnail file altogether.

Something is not adding up right there. Debian version 1.0.4985-1 corresponds jitsi-meet tag 5870 which was released with latest commit as 450c961e6846c16035c56a6a9880fe65a3f610db. Jitsi meet tag 4985 was released in September 2020.

You can see released versions here: jitsi-meet-release-notes/CHANGELOG-WEB.md at master · jitsi/jitsi-meet-release-notes · GitHub.
If your debian version is really 1.0.4985-1, then this is the correct release tag Release 2.0.5870 · jitsi/jitsi-meet · GitHub

I’m so sorry for wasting your time! You are absolutely right. I just got your PR applied against the stable version. I’m building now and will try it out tonight.

After a bit of a struggle, I have successfully applied your patch to tag stable/jitsi-meet_5870.

However, when I try to execute api.setParticipantVolume() I get an error: “Uncaught TypeError: api.setParticipantVolume is not a function”.

I’m sure I’m still doing something wrong. Here’s my full process - if you have any suggestions on what I can do differently to get it working I would very much appreciate it!

Clone and patch

git clone https://github.com/jitsi/jitsi-meet
git checkout -b setaudiolevels stable/jitsi-meet_5870     
npm install
git remote add izakgl https://github.com/izakgl/jitsi-meet
git remote update izakgl        
git cherry-pick d5ea0b3e215346f556a9a9b731d0acaa188cf795 
git cherry-pick fc71470a7b85af0ef3f6ad46c6735d701ca0e669
make      

Copy to server

rsync libs/app.bundle.min* root@server:/usr/share/jitsi-meet/libs/
rsync libs/external_api.min* root@server:/usr/share/jitsi-meet/libs/
rsync libs/lib-jitsi-meet.min* root@server:/usr/share/jitsi-meet/libs/     

Am I missing any files from this list?

And here’s the code I’m using to test:

const domain = 'meet.server.org';
const options = {
				roomName: 'JitsiMeetJamieExample',
				width: 700,
				height: 700,
				parentNode: document.querySelector('#meet')
		};
		const api = new JitsiMeetExternalAPI(domain, options);

		document.getElementById("interpret-on").addEventListener("click", function() {
			var participants = api.getParticipantsInfo();
			console.log(participants);
			participants.forEach(function(value, index, arr) {
				console.log("Id: ", value.participantId);
				api.setParticipantVolume(value.participantId, 0);
			});

		});

The call to getParticipantsInfo() completes successfully, but for some reason the new setParticipantVolume fails. I must be missing a required file in my rsync? (I’ve carefully ensured that my cache is clear).

Success! I just added the following to your PR and now it works as expected! :slight_smile:

diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index 93e257e22..f5beb7ae2 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -973,6 +973,10 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
         this.executeCommand('pinParticipant', participantId);
     }
 
+    setParticipantVolume(participantId, volume) {
+        this.executeCommand('setParticipantVolume', participantId, volume);
+    }
+
     /**
      * Removes event listener.
      *

Oh yeah, I didn’t add a function for that, but you can call it very similarly to how you call it in the function. This is also valid:

const api = new JitsiMeetExternalAPI(domain, options);
...
api.executeCommand('setParticipantVolume', participantId, volume);

Got it - thanks for that. I’ve adjusted my code to use that call instead. For anyone who is interested, I’ve published my code that supports simultaneous (2 language) interpretation in a Jitsi Meet meeting using the Iframe API here: May First Movement Techology / jsi · GitLab - but remember, it depends on this pull request: feat(external_api): Control participant volume by izakgl · Pull Request #9322 · jitsi/jitsi-meet · GitHub

2 Likes