playlist

The playlist is an array-like object.
It exposes indexed elements (accessible via bracket notation), a playlist.length property and a playlist.push method.
Every element in the playlist array is a Node instance, to be played in sequence by the player.

Example

var player = new InterludePlayer('#playerContainer');
...
player.playlist.push('myNode');
...
for (var i = 0; i < player.playlist.length; i++) {
    console.log(player.playlist[i].id);
}

Properties

player.playlist.length : number
propertyreadonly

The length property specifies the number of node elements in the playlist array.

Example

player.playlist.push('node1');
console.log(player.playlist.length); // 1

Methods

player.playlist.push() ⇒ number
method

Push a node (or nodes) into the playlist array.
Accepts one or more arguments, every argument should either be a string (node id) or object (node instance).

Returns: number - The new length of playlist array
See: playlistpush

Param Type Description
…node string | Node A node id (of a node that exists in repository), or a node object.

Example

// Pushing two nodes into the playlist (using node IDs):
player.playlist.push('node1', 'node2');

// Pushing a node into the playlist using node object:
var nodeObj = player.repository.get('node1');
player.playlist.push(nodeObj);

player.playlist.reset()
method

Clears all nodes from the playlist array (does not affect nodes in repository).
A side effect of calling this method, is that playback will be stopped (if currently playing).

See: playlistreset
Example

player.playlist.reset();
console.log(player.playlist.length); // 0

player.playlist.timeOffsetAtIndex(index) ⇒ number
method

Returns the time offset (in seconds) from the beginning of playlist, to the start of a node at given index.

Returns: number - Time in seconds, from beginning of playlist to start of node at given index.

Param Type Description
index number An integer in the range [0, playlist.length].

Example

var timeInNode = player.currentTime - player.playlist.timeOffsetAtIndex(player.currentNodeIndex);
var remainingTimeInNode = player.currentNode.duration - timeInNode;
Rate this page: X
Tell us more!