<script src="https://embed.videodelivery.net/embed/sdk.latest.js"></script>
<iframe id="player" src="https://iframe.videodelivery.net/4ac8d3440a3ce09aa33f4ede48e29885"></iframe>
<br><br>
<button onclick="player.currentTime = 600;">Go To 10:00</button>
<button onclick="player.currentTime = player.duration - 1;">Trigger Ended Event</button>
<!--
INITIAL PLAY QUICKLY TRIGGERS SEEK NEARLY EVERY TIME (???)
play at 1640154277250 (48321ms) position 0
seeked at 1640154277317 (67ms) position 0.08
USER SEEK AHEAD TRIGGERS PAUSE (???), PLAY (while already playing whut?), SEEK
pause at 1640154278965 (1648ms) position 1.651625
play at 1640154279055 (90ms) position 1.651625
seeked at 1640154279597 (542ms) position 1367.213115
USER SEEK BACKWARDS DITTO
pause at 1640154282432 (2835ms) position 1370.036427
play at 1640154282523 (91ms) position 1370.036427
seeked at 1640154284450 (1927ms) position 275.660901
SDK GO TO 10:00 WHILE PLAYING CONTINUES PLAYING
seeked at 1640154289400 (4950ms) position 600
PAUSE
pause at 1640154294577 (5177ms) position 602.752166
SDK GO TO 10:00 WHILE PAUSED DOES NOT TRIGGER PLAY
seeked at 1640154299872 (5295ms) position 600
PLAY
play at 1640154307069 (7197ms) position 600
PAUSE
pause at 1640154310744 (3675ms) position 603.304833
USER SEEK WHILE PAUSED TRIGGERS PLAY
play at 1640154315492 (4748ms) position 603.304833
seeked at 1640154316872 (1380ms) position 1514.754098
TRIGGER ENDED
seeked at 1640154321414 (4542ms) position 1799
pause at 1640154322658 (1244ms) position 1800.01
ended at 1640154322659 (1ms) position 1800.01
-->
var timePrevious = Date.now();
var player;
document.addEventListener("DOMContentLoaded", function(event) {
player = Stream(document.getElementById('player'));
player.addEventListener('play', () => logTimeAndPosition('play'));
player.addEventListener('pause', () => logTimeAndPosition('pause'));
player.addEventListener('seeked', () => logTimeAndPosition('seeked'));
player.addEventListener('ended', () => logTimeAndPosition('ended'));
});
function logTimeAndPosition(event) {
var timeNow = Date.now();
var msDiff = timeNow - timePrevious;
timePrevious = timeNow;
console.log(`${event} at ${timeNow} (${msDiff}ms) position ${player.currentTime}`);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.