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

Jamie, this is exactly what I need. However, I am pretty new to jitsi, so I was wondering if you have a step by step instructions on how to enable this on a Jitsi server. I went to your gitlab page, and I was a bit confused on the installation. TIA!

@jamie Thanks.
At what version of jitsi-meet you have tested it. If you have built version of jitsi-meet after applying feat(external_api): Control participant volume by izakgl · Pull Request #9322 · jitsi/jitsi-meet · GitHub can you share it.
Thanks

I managed to get it working, however there are 2 issues noted:

  1. On Iphone & Ipad, selection can not work and user listens to both live & interpretation ( Although volume levels are changed on each tile but still both sounds are heard)
  2. While Jibri recording I was expecting that there will be a mix of voices ( live+ interpretation) but to my surprise there is no voice on whole recording.
    Any pointers.
    Thank you

I’m glad you sorted it out @kkd. For the record, we are running Jitsi Meet from Debian (version 1.0.4985-1) which corresponds to the Jitsi Meet tag 5870. See my comment above for the exact steps to take to patch that version.

Or - you can simply download these updated files and copy them to your jitsi meet lib directory (but be sure you are running the exact Debian version - 1.0.4985-1).

And yes, I’ve simply told people: you can only participate via Chrome or Firefox on a desktop computer. It does, in fact, work on some newer android devices but I haven’t found an iThing that works properly with it. I would be thrilled if someone figured out what we need to change to get that to work.

And I’m also surprised with your jibri recording results and would have also expected a mix. Unfortunately I have no pointers, but am curious to know if you figure anything out.