简体   繁体   English

HTML5视频控件(静音按钮)

[英]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. 试图使声音图标“ .sound”在单击时使html5视频“ .intro-movie”静音或取消静音。

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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