The repository stores all nodes known to the player.
Nodes are retrievable via their string ID.
Example
var player = new InterludePlayer('#playerContainer');
var nodeConfigObject = {
id: 'myNode',
source: {
version: '2.1.2',
id: 'fdbf8d91-56c4-4de1-ada7-17a9bc8252ca',
metadata: {...},
representations: [
{...},
{...}
]
}
};
player.repository.add(nodeConfigObject);
player.playlist.push('myNode');
Methods
player.repository.add() ⇒ Node
| Array.<Node>
Adds a node to the repository.
The added node can later be referenced by id when pushing to playlist.
The method accepts either a single node config object, or an array of objects, or multiple arguments.
If the node alredy exists it will override previous instance and log a warning.
The nodeConfigObj
object MUST contain a string id
and a source
property.
For more information regarding IVDs, see the encoding guide.
Returns: Node
| Array.<Node>
- A node instance, or an array of instances.
See: Node, repository.get, repository.update, repository.remove, repository.has
Param | Type | Description |
---|---|---|
…nodeConfigObj | object | Array.<object> |
A node config object, or an array of node config objects, or multiple node config objects. |
nodeConfigObj.id | string |
Required. A string id for the node. Should be unique among the nodes registered with this repository instance. |
nodeConfigObj.source | object | string | function |
Required. An IVD file (Interlude Video Descriptor). Valid values are: - Contents of an IVD file (as an object or a JSON string). - An absolute URL pointing to an IVD file. - The string null or any falsy value (will produce a null-node with duration 0).- A function that returns a valid value, or a promise that resolves with a valid value. |
[nodeConfigObj.prefetch] | Array.<string> |
Optional. List of prefetch node IDs. See addPrefetch. |
[nodeConfigObj.data] | object |
Optional. Any additional data to be attached to the node for later usage. |
Example
player.repository.add({id: 'myNode', source: ...});
player.playlist.push('myNode');
player.repository.update() ⇒ Node
| Array.<Node>
Updates a pre-existing node in the repository (will be matched by id).
The method accepts either a single node config object, or an array of objects, or multiple arguments.
If node does not exists it will add a new node and issue a warning.
Returns: Node
| Array.<Node>
- The updated node instance, or an array of instances.
See: Node, repository.add, repository.get, repository.remove, repository.has
Param | Type | Description |
---|---|---|
…nodeConfigObj | object | Array.<object> |
A node config object, or an array of node config objects, or multiple node config objects. |
player.repository.get() ⇒ Node
| Array.<Node>
Get a reference to a node (or nodes) by id.
Supports the special value all
, which will return all nodes in repository.
The method accepts either a single id, or an array of ids, or multiple ids.
Returns: Node
| Array.<Node>
- The requested Node object or objects.
See: Node, repository.add, repository.update, repository.remove, repository.has
Param | Type | Description |
---|---|---|
…id | string | Array.<string> |
A node id, or an array of ids, or multiple ids, or special value all . |
Example
var nodes = player.repository.get('all');
for (var i = 0; i < nodes.length; i++) {
console.log(nodes[i].id);
}
player.repository.remove()
Deletes a node (or nodes) from repository.
Can only be called when playlist is empty (otherwise error will be logged).
Supports the special value all
, which will delete all nodes in repository.
The method accepts either a single id, or an array of ids, or multiple ids.
If node does not exist, it will log a warning.
See: Node, repository.add, repository.update, repository.get, repository.has
Param | Type | Description |
---|---|---|
…id | string | Array.<string> |
A node id, or an array of ids, or multiple ids, or special value all . |
Example
player.repository.remove('myNode');
player.repository.has(id) ⇒ boolean
Checks whether a node with given id exists in repository.
Returns: boolean
- True if exists in repository, false otherwise.
See: Node, repository.add, repository.update, repository.get, repository.remove
Param | Type | Description |
---|---|---|
id | string |
A node id. |
Example
if (!player.repository.has('myNode')) {
player.repository.add({id: 'myNode', ...});
}
player.repository.reset()
Deletes all nodes in the repository.
Can only be called when playlist is empty (otherwise error will be logged).
Example
player.repository.reset();
player.repository.get('all'); // Empty array: []