Onended

From XPUB & Lens-Based wiki

This is an example of triggering an action when a video has finished using HTML5's onended event.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style>
#buttons {
    position: absolute;
    z-index: 10;
    left: 10px;
    top: 10px;
    width: 240px;
    background: pink;
    padding: 50px;
    visibility: hidden;
}
</style>
</head>
<body>

<video onended="showbuttons()" autoplay src="http://localhost/video/green2red.webm" ></video>

<div id="buttons">
<button>watch more fun things</button>
<button>watch serious things</button>
<button>watch random things</button>
</div>

<p>More content on the page</p>

<script>


function showbuttons() {
    console.log("all done");
    // ok, make some buttons appear
    document.getElementById("buttons").style.visibility = "visible";
}
</script>
</body>
</html>