Sebastian Jennings Almnes Sebastian Jennings Almnes - 7 months ago 52
Javascript Question

toggle mute and unmute with javascript

I'm trying to create a button for muting and un-mute.

Initially I have by button set up like this:

<i class="fa fa-microphone" id="audio"></i>

and what I want is that when you click it, the class becomes:

<i class="fa fa-microphone-slash" id="audio"></i>

now I have my javascript set up like this:

$(document).ready(function() {
$('#audio').click(function() {

which essentially mutes it, now I need to make it so that it can also unmute when I click on the button


you can check if the publisher is sending video/audio on the stream it self like this:

then you can use the ! (bang) to invert it


so to toggle the class aswell you do someting like

$(document).ready(function() {
    var toggleAudioBtn = $('#audio') {