0
$(".sound").click(function() {
  if ($(".intro-movie").prop('muted', true)) {

    $(".intro-movie").prop('muted', true);

    $(".sound").addClass("muted");

  } else {

    $(".intro-movie").prop('muted', false);

    $(".sound").removeClass("muted");
  }

});

Trying to get the sound icon ".sound" to mute or unmute the html5 video ".intro-movie" when clicked.

ericksonsce
  • 27
  • 2
  • 5
  • Maybe your `if ($(".intro-movie").prop('muted', true))` has to be `if ($(".intro-movie").prop('muted', false))`. Now it seems: if(muted) then mute else unmute – Anto Jurković Nov 10 '13 at 21:53
  • if statemet should be changed. And this Q is duplicate of similar Qs [1st link](http://stackoverflow.com/questions/6442427/muting-a-html5-audio-element-using-a-custom-button?lq=1), [2nd link](http://stackoverflow.com/questions/6376450/how-to-mute-an-html5-video-player?lq=1) – Anto Jurković Nov 10 '13 at 22:11

1 Answers1

1

I tried may examples, and I finally made it myself. It works perfectly.

function mute() {
if(myaudio.muted)   {
    myaudio.muted=!myaudio.muted;
    document.getElementById("volume").style.backgroundImage = "url(resources/vol.png)";
}else{
    myaudio.muted=!myaudio.muted;
    document.getElementById("volume").style.backgroundImage = "url(resources/mute.png)";
}

}