Last active
June 27, 2022 05:16
-
-
Save karla001/82e532afcb569d74895fea351f54a4d5 to your computer and use it in GitHub Desktop.
Used to mute and unmute an HTML <audio> tag when mute button was clicked.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sound(){ | |
$mutebutton.on('click',function(event) { | |
if($audio[0].muted === false){ | |
$audio.attr('muted',true) | |
$audio[0].muted = true; | |
$mutebutton.text('Unmute'); | |
console.log('Muted'); | |
}else if($audio[0].muted === true){ | |
$audio.removeAttr('muted') | |
$audio[0].muted = false; | |
$mutebutton.text('Mute'); | |
console.log('Unmuted'); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This piece of code solved a problem dealing with a unique type of audio that was being captured by a hardware technology that was specific to said enterprise. The front end was able to take the information being given by the backend point and play only the latest audio file while also giving the user the ability to mute and unmute the audio.