Detect when an HTML5 video finishes

You can add an event listener with ‘ended’ as first param

Like this :

<video src="https://stackoverflow.com/questions/2741493/video.ogv" id="myVideo">
  video not supported
</video>

<script type="text/javascript">
    document.getElementById('myVideo').addEventListener('ended',myHandler,false);
    function myHandler(e) {
        // What you want to do after the event
    }
</script>

Leave a Comment