Search code examples
javascripthtmlaudio

How to check if an audio is playing?


What's the JavaScript API for checking if an HTML5 audio element is currently playing?


Solution

  • function isPlaying(audioEl) {
      return !audioEl.paused;
    }
    

    The Audio tag has a paused property. If it is not paused, then it's playing.