<script> var audio = document.getElementById('audio_with_controls'); if (audio.ended) { alert("test") }; </script>