Limite de lecture audio à l'aide de jQuery

<audio id="audio_file" class="myAudio" controls >
  	<source src="sound.ogg" type="audio/ogg">
	<source src="sound.mp3" type="audio/mpeg">
</audio>
<script>

// Audio file will be played two times only after that is any user tries to play it won't work.
  var loopCount = 0;

  $('#audio_file').on('ended', function(){
    loopCount++;
  })
  $('#audio_file').on('play', function(){
    if(loopCount == 2) {
      this.pause();
    }
  })
</script>
Terrible Tern