I need to add a custom mute/unmute button to a VideoJs player (when I click on the button if it's muted it should unmute and if it's unmuted then it should mute).
I tried to do this in the following way with JavaScript but it doesn't work. Could you help me fix this?
const muteButton = document.querySelector(".mute-btn11");
muteButton.addEventListener("click", function() {
var video = videojs("myVideo");
const booleanValue = video.muted.valueOf();
console.log(booleanValue);
if (booleanValue == true) {
video.muted(false);
} else {
video.muted(true);
}
});
<video controls autoplay playsinline id="myVideo" class="video-js vjs-16-9 vjs-big-play-centered"></video>
<button class="mute-btn11"> Mute </button>