Open Parfyonator opened 1 year ago
Hi. Any suggestions? Is it possible to implement? It would be very helpful.
Same request
After some digging I was able find a way to do it. As it turns out there is a class Helper in the main dependency flutter_webrtc. And one can change the volume of remote participant like this:
final desiredVolumeLevel = 0.7; // Some new audio level
final firstAudioTrack = participant.audioTracks[0]; // Get first audio track of participant
Helper.setVolume(desiredVolumeLevel, firstAudioTrack.track!.mediaStreamTrack);
But there is a catch. It only works with Android. On iOS it doesn't work because of this issue. Since this issue wasn't addressed the problem still persist. At the same time I can confirm that the root of the problem mentioned in the issue thread is indeed correct, since I've tried the proposed "solution" and it worked: I was able to change the volume of remote participant on iOS device.
@cloudwebrtc @hiroshihorie since it looks like you are one of the main contributors to the flutter-webrtc project, can you please address this issue and fix it in the future version of the package or provide appropriate hotfix. Thanks in advance.
It turns out that there was updated recently (~2 weeks ago) to version 0.9.25 and the issue was fixed. The latest livekit sdk version for flutter (1.2.2) bumped the flutter-webrtc dependency up to version 0.9.25 so the issue with iOS is gone.
@acgacgacgacg you can use the snippet from the comment above to control the volume level of the remote participants with the latest version of livekit client.
@hiroshihorie @cloudwebrtc although the issue can be closed, it would be nice to have setVolume
method for a track the same way it has methods for mute/unmute. Would it be possible to add in the future livekit client versions?
@Parfyonator
Thanks for your help.
Have you figured out how to get the audio level, i.e. the volume?
The RemoteParticipant.audioLevel
is always 0.
Is your feature request related to a problem? Please describe.
Currently I can only subscribe and unsubscribe to/from an audio track which may be inconvenient if one of the participants is too loud or too quite.
Describe the solution you'd like
Implement
setVolume
method for remote audio track similar to JS client where you can control the audio volume level locally: https://docs.livekit.io/client-sdk-js/classes/RemoteAudioTrack.html#setVolumeAt least it look like it is how it's done for web according to the implementation which uses
GainNode
: https://github.com/livekit/client-sdk-js/blob/07566556ce593ca82f66bee1cc5329ff512f60c2/src/room/track/RemoteAudioTrack.ts#L42Describe alternatives you've considered
Change audio level at backend. But this audio level change will be for all of the participants which is not good. Maybe insertable streams would help when they are implemented.
Additional context
I'm trying to stream music to a room from files but I want all of the participants to adjust the audio level of this "player participant" locally.