control

The control plugin exposes some general playback controls, such as stop and replay.

Example

myStopButton.addEventListener('click', function() {
    player.control.stop();
});

Init Options

options : object

Initialization options for the control plugin.

options.active : boolean
property

Initial mode of the control plugin. See active.

Default: true
See: active
Example

// playerOptions.json
{
    "plugins": {
        "control": {
            "active": false
        }
    }
}

options.fastReplay : boolean | string
property

Should we use the fast replay mechanism?
Valid values are true, false and/or a node id.
When value is truthy, plugin will automatically invoke stop on ended event.
A later call to replay will simply call player.play.
If string node id given, it will use it as the head node for replay calls, in case no argument was given to replay function.

Default: true
See: replay
Example

// playerOptions.json
{
    "plugins": {
        "control": {
            "fastReplay": "node_replay_a34f5g"
        }
    }
}

Properties

player.control.active : boolean
property

The control plugin’s active mode.
If set to true, on stop/replay the playlist will be reset and only the replay node will be pushed.
If false, playlist will remain intact.

Default: true
Example

// Passive replay
player.control.active = false;
player.control.replay();

player.control.replayNode : Node
property

The node that should be pushed to playlist on stop/replay (if no argument given).
Only relevant when in active mode.
You can set it with either a string (node id) or a Node object or array of strings or Node objects.

Default: null
Example

player.control.replayNode = 'myNodeId';
player.control.active = true;

if (player.control.replayNode) {
    player.control.replayNode.once('nodestart', function() {
        console.log('Replay started!');
    });
    player.control.replay();
}

player.control.replayNode = ['myFirstReplayNodeId', 'mySecondReplayNodeId'];

if (player.control.replayNode && Array.isArray(player.control.replayNode)) {
    player.control.replayNode[0].once('nodestart', function() {
        console.log('Replay started!');
    });
    player.control.replay();
}

player.control.version : string
propertyreadonly

The control plugin’s version string.

Example

console.log('The control plugin version is', player.control.version);

Methods

player.control.stop([replayNode])
method

Stops the video playback.
The control.stop event will be triggered when operation completes.
When in passive mode (i.e. active is false), this will stop and seek to start, while keeping playlist intact.
In active mode (default), this will stop, clear the playlist, and push the replay node.
The replay node used will be determined by the following descending order of preference:

  1. An explicit replayNode argument (if given)
  2. The replayNode property (if set)
  3. The fastReplay init option (if set to a string)
  4. The first node in the current playlist
Param Type Description
[replayNode] Node | string Optional. New replay node (only relevant when in active mode).

Example

player.on('control.stop', function() {
     player.play();
     console.log(player.currentNode); // node_A
});
player.control.stop('node_A');

player.control.replay([replayNode])
method

Restarts the video playback (stop and play).
The control.replay event will be triggered when operation completes.
When in passive mode (i.e. active is false), this will stop and seek to start, while keeping playlist intact.
In active mode (default), this will stop, clear the playlist, and push the replay node.
The replay node used will be determined by the following descending order of preference:

  1. An explicit replayNode argument (if given)
  2. The replayNode property (if set)
  3. The fastReplay init option (if set to a string)
  4. The first node in the current playlist
Param Type Description
[replayNode] Node | string Optional. New replay node (only relevant when in active mode).

Example

player.control.replay();

Events

“control.stop”
event

Triggered when stop operation is completed.

“control.replay”
event

Triggered when replay operation is completed.

Rate this page: X
Tell us more!