Skip to main content

Timed Call To Action

Making your own "Call To Action" logic with timeupdate events and the currentTime() method is simple. This event is fired every time the player's time is updated, so you can use it to check if the current time is equal to a specific time and then do whatever you want.

// Flag to prevent the anchor from being triggered more than once
let isAnchorTriggered = false;
// Time in seconds
const targetTime = 10;

player.on('timeupdate', () => {
// If the anchor was already triggered, do nothing
if (isAnchorTriggered) return;

// If the current time is equal to the target time, trigger the anchor
if (player.currentTime() >= targetTime) {
isAnchorTriggered = true;
console.log(`Anchor is triggered at ${targetTime} seconds.`);
}
});