Node

The Node object represents a chunk of video.
It is the primary currency of the InterludePlayer. It’s used with the playlist and the repository.
Creating a node instance is simply a matter of calling repository.add.
To get a reference to a node instance, call repository.get.

Properties

node.isParallel : boolean
propertyreadonly

Is this a parallel node?
A parallel node is defined as a node that has more than one video track or more than one audio track.
You can call player.switch() while a parallel node is playing to switch to a different video/audio track.

See: player.switch(), audioTracksCount, videoTracksCount

node.audioTracksCount : number
propertyreadonly

Number of audio tracks in the node.
Value is equal to the length of the array returned by getAudioTracks.

See: getAudioTracks

node.videoTracksCount : number
propertyreadonly

Number of video tracks in the node.

node.autoSwitchingEnabled : boolean
property

Is auto switching enabled?
If true (default), player will automatically switch to the defaultVideoTrackIndex and defaultAudioTrackIndex once node playback begins.
Setting this value to false will disable the automatic switching behavior.

Default: true
See: defaultVideoTrackIndex, defaultAudioTrackIndex

node.defaultAudioTrackIndex : number
property

When autoSwitchingEnabled is set, player will automatically switch to this default audio track once node playback begins.

Default: 0
See: autoSwitchingEnabled

node.defaultVideoTrackIndex : number
property

When autoSwitchingEnabled is set, player will automatically switch to this default video track once node playback begins.

Default: 0
See: autoSwitchingEnabled

node.currentAudioTrackIndex : number
property

The index of the selected audio track (0-based).
If more than one audio track is unmuted (see getAudioTracks), or if all audio tracks are muted, value will be -1.
Setting the currentAudioTrackIndex value will reset all audio tracks to volume 1 and mute all other tracks besides the selected one.
Setting this value during node playback will cause audio track to switch.

See: audioTracksCount

node.currentVideoTrackIndex : number
property

The index of the selected video track (0-based).
Setting this value during node playback will cause video track to switch.

See: videoTracksCount

node.volume : number
property

The master volume for this node.
All tracks are affected by this value.

Default: 1
See: muted, volumechange

node.muted : boolean
property

The master muted state for this node.
All tracks are affected by this value.

Default: false
See: volume, volumechange

node.duration : number
propertyreadonly

The duration of the node in seconds.

Example

let headNode = player.playlist[0];
console.log(`Head node duration is ${headNode.duration} seconds`);

Methods

node.getAudioTracks() ⇒ Array.<AudioTrack>
method

Returns an array of AudioTrack objects representing the audio tracks associated with this node.

Returns: Array.<AudioTrack> - An array of AudioTrack objects.
Example

const myNode = player.repository.get('node_mynodeid');

// Unmute all tracks so they'd all play in parallel
myNode.getAudioTracks().forEach(audioTrack => {
    audioTrack.muted = false;
});

node.on(evt, listener)
method

Adds a listener function to the specified event on the node.
If the listener function returns true then it will be removed after it is called.
If you pass a regular expression as the event name then the listener will be added to all events that match it.

See: once, off, trigger

Param Type Description
evt string | RegExp Name of the event to attach the listener to.
listener function Method to be called when the event is triggered. If the function returns true, then it will be removed after calling.

node.off(evt, listener)
method

Removes a listener function from the event on the node.
When passed a regular expression as the event name, it will remove the listener from all events that match it.

See: on, once, trigger

Param Type Description
evt string | RegExp Name of the event to remove the listener from.
listener function Method to remove from the event.

node.once(evt, listener)
method

Adds a listener function to the event on the node, this listener will automatically be removed after first execution.
If you pass a regular expression as the event name then the listener will be added to all events that match it.

See: on, off, trigger

Param Type Description
evt string | RegExp Name of the event to attach the listener to.
listener function Method to be called when the event is triggered.

node.trigger(evt)
method

Triggers an event of your choice.
When triggered, every listener attached to that event will be executed.
If you pass the optional arguments then those arguments will be passed to every listener upon execution.

See: on, once, off

Param Type Description
evt string | RegExp Name of the event to emit and execute listeners for.
[…args] * Optional arguments to be passed to each listener.

node.addPrefetch(prefetchNodeId) ⇒ Node
method

Adds a prefetch to a node.
Every node object contains a prefetch array, which consists of other node ids.
These ids are a hint to the player, that one of these prefetch nodes are likely to be pushed to the playlist following this node.
The player will use this hint in order to try and preload children once loading of this node completes.
If this node already contains the child prefetchNodeId, it will do nothing.

Returns: Node - This node object.
See: removePrefetch

Param Type Description
prefetchNodeId string Child node id.

Example

const myNode = player.repository.get('node_myNodeId');
myNode.addPrefetch('node_childId');

node.removePrefetch(prefetchNodeId) ⇒ Node
method

Removes a prefetch from a node.

Returns: Node - This node object.
See: addPrefetch

Param Type Description
prefetchNodeId string Child node id.

Example

const myNode = player.repository.get('node_myNodeId');
myNode.removePrefetch('node_noLongerChildId');

Events

“volumechange”
event

Triggered when the node’s volume and/or muted properties change.

“nodestart”
event

Triggered when node playback has started.
This event will also be triggered when seeking within the node.

Param Type Description
node Node Node object.
index number Node’s playlist index (0 based).

“nodeend”
event

Triggered when node playback has completed.

Param Type Description
node Node Node object.
index number Node’s playlist index (0 based).

“nodecritical”
event

Triggered when node playback reached a critical point (nearing nodeend event).
Unlike the playlistcritical event that’s triggered on the player, this event (which is triggered on the node instance)
is triggered regardless of whether or not a next node has been pushed to the playlist.

Param Type Description
node Node Node object.
index number Node’s playlist index (0 based).

“playlistpush”
event

Triggered when playlist.push() was called with this node.

See: playlist

Param Type Description
node Node The node that was pushed to playlist (this node).
index number The node’s playlist index (0 based).

“timeupdate”
event

This special event can be used to trigger a callback when node’s playback reaches a certain time (aka a cuepoint).
The timeupdate event accepts a time argument (in seconds) in the event name (delimited by : - see example).
When this time argument is a positive number, it refers to seconds from start of node.
A negative number refers to seconds before end of node.

Param Type Description
node Node Node object.
timeInNode number Time in seconds from start of node.

Example

const myNode = player.repository.get('node_myNodeId');
const callback = (node, timeInNode) => {
    myNode.off('timeupdate:3.25', callback);
    console.log(`Playback time in "${node.id}" has reached ${timeInNode} seconds!`);
};
myNode.on('timeupdate:3.25', callback);
Rate this page: X
Tell us more!