简体   繁体   中英

HTML5 Video Controls (Mute Button)

$(".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.

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)";
}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM