Remember playback position of a lightbox player when closed

Remembering the playback position of a video when the lightbox closes is quite simple using afterglow's event system.

Let's assume you have this very basic lightbox player setup:

<!DOCTYPE html>
    <title>afterglow player</title>
    <script src="//"></script>
    <a class="afterglow" href="#myvideo">Launch lightbox</a>
    <video id="myvideo" width="960" height="540">
    	<source type="video/mp4" src="/path/to/myvideo.mp4" />

All you have to do to make the playback position sort of permanent when the lightbox closes, is this:

var lastposition = 0;

afterglow.on('myvideo', "before-lightbox-close", function(event) {
  // Store the playback time
  lastposition = event.player.currentTime();

afterglow.on('myvideo', "ready", function(event) {
  // Load the playback time

That's it. If you wan't to play around with this, take a look at this pen.