title: Detect when audio.play() has finished
body: <p>I'm using <code>audio.play()</code> inside my React project to trigger a clip onClick, but I'm having trouble figuring out how to determine when the clip has stopped playing so I can do something after it has finished.</p>
  
  <pre><code>class Soundboard extends Component {
      getAudio = (clipUrl) =&gt; {
          var audio = new Audio(clipUrl);
          return audio.play();
      };
  
      render() {
          return (
            &lt;div
                onClick={() =&gt; this.getAudio(pathToClip)}
            /&gt;
  
          );
      }
  }
  </code></pre>