How to remove and reinsert audio during video transmission (mute X)

hyuk

Member
I've learned that during video broadcasting, it's possible to remove only the audio without interrupting the video. I understand that I can use addTrack to reintroduce the audio without interrupting the video. However, I'm unsure how to create an audio stream. Could you advise me on the methods I can use for this? I've used createRoom from RoomApi.sdk to generate the stream. Thank you.
Code:
const audioTrack = localVideo.childNodes[0].srcObject.getAudioTracks()[0];
        if (audioTrack) {
            await localVideo.childNodes[0].srcObject.removeTrack(audioTrack);
            audioTrack.stop();
        }

Below is code that does not work and is written as an example.
Code:
//const audioStream =RoomApi.sdk.createStream({audio:true, video:false});
await localVideo.childNodes[0].srcObject.addTrack(audioStream.getAudioTrack());
I would like the recording to be natural as well. Is this a possible scenario?
 
Last edited:

Max

Administrator
Staff member
Good day.
You don't need to remove audio track to mute it. Use Stream.muteAudio() method, for example (Conference sample source code)
Code:
    $("#localAudioToggle").text("Mute A").off('click').click(function(){
        if (stream.isAudioMuted()) {
            $(this).text("Mute A");
            stream.unmuteAudio();
        } else {
            $(this).text("Unmute A");
            stream.muteAudio();
        }
    }).prop('disabled', false);
 

hyuk

Member
I wrote it down as a title, but I'm planning to use the microphone permissions for a short time elsewhere.
For muteAudio, microphone resources were still being used by webrtc.
I would like to delete the audio track, use its microphone permissions on another resource, and then get the permissions again when I am done. I wish there was a way.
 
Last edited:

Max

Administrator
Staff member
WebSDK does not support track adding or removing. Perhaps we will support it in the next major version, but it is not a priority task and will take a long, long time to release.
 
Top