Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot disable localParticipant.audioTracks with Twilio Video

I'm adapting Twilio's JS Quickstart and trying to provide a button that will mute a user's audio. From looking around online, my code looks like this:

function toggleAudio(){
  room.localParticipant.audioTracks.forEach(function(track) {
    console.log(track);
    track.disable();
  })
}

The console.log() spits out a LocalAudioTrackPublication, yet I get the following error:

Uncaught TypeError: track.disable is not a function

So I'm stumped. The docs imply that the .disable() method will do what I expect, yet apparently, it's not defined?

like image 480
Kevin Lewis Avatar asked Sep 11 '18 10:09

Kevin Lewis


1 Answers

It was such a ridiculously simple solution, as is always the case.

function toggleAudio(){
  room.localParticipant.audioTracks.forEach(function(track) {
    track.track.disable();
  })
}

The actual track is inside of the track property.

like image 78
Kevin Lewis Avatar answered Oct 29 '22 05:10

Kevin Lewis