'Pop noise' sounds when audio paused with Javascript

后端 未结 1 878
囚心锁ツ
囚心锁ツ 2021-01-16 08:30

I have an audio tag in my html, and which I have .wav inside it. With Javascript, I select audio tag and play the wav., which I trigger using a keyboard key. What I am t

1条回答
  •  悲哀的现实
    2021-01-16 09:13

    Update:

    I think I need to use fade out to work around this issue. Is there a way to fade out audio instantly?

    You can use .animate() to animate volume property from current value to 0

    var audio = $("audio");
    $("button").click(function() {
      if (audio[0].volume > 0) {
        audio.animate({volume:0});
        // call `.pause()` here
      }
    });
    
    
    

    0 讨论(0)
提交回复
热议问题