Handling an Exit Point

When you define a decision on Eko Studio and you set the connections between the parent node to its children, you can choose between two options - connect on node end or connect on click. The first, when a decision is made, will push the chosen child to the playlist and play it after the parent node ends. The second also will push the child node to the playlist, but it immediately seek to that node and won’t wait until the parent node ends.

Sometimes you will want to have a bit different functionality like jumping to the chosen child, but not immediately and not when the parent node ends, but on pre-defined cue points within the parent node.

Here is how you can implement that kind of functionality

let nodeId = 'node_with_exit_point';

// customExitPoints are times in seconds within the node;
// i.e. 10 is 10 seconds after the node starts
let customExitPoints = [2.5, 5, 7.5, 10];

// Double check that the nodeId is valid
if (!player.repository.has(nodeId)) {
    console.error(nodeId, 'is not a valid node id. Please check the id');
let nodeToExit = player.repository.get(nodeId);
let nodeToExitDecision = player.decision.get(nodeId);

function exitIfDecisionMade() {
    if (nodeToExitDecision.state === 'made' &&
        player.currentNodeIndex === player.playlist.length - 2) {
        // Seek to the chosen child node
        player.currentNodeIndex += 1;
customExitPoints.forEach(function(exitPoint) {
    nodeToExit.on('timeupdate:' + exitPoint, exitIfDecisionMade);

See also decision instance state property and Node timeupdate event.

Rate this page: X
Tell us more!