The nativeformat player has the ability to run scripts alongside its rendering of a graph in order to allow for dynamically changing the nodes/edges within a particular graph as well as interacting with outside messages.
The Javascript API is broken down into a object-orientated architecture.
Here we have the ability to get the player object from the global scope:
class NF {
getPlayer(): Player;
}Example:
var player = global.NF.getPlayer()After the player has been obtained from the global scope, we can use its API to modify it.
class Player {
let graphs: [Graph];
let scripts: [Script];
let loaded: bool;
renderTime: number;
playing: bool;
registerMessage(message_identifier: string, sender_identifier: string, callback: function): int;
sendMessage(message_identifier: string, message_type: int, payload: Object);
unregisterMessage(handle: int);
toJSON(): string;
setJSON(json: string);
}A graph is a piece of information telling us how to render a particular piece of content.
class Graph {
let nodes: [Node];
let edges: [Edge];
let outputNode: Node;
let identifier: string;
let type: string;
toJSON(): string;
setJSON(json: string);
addNode(node: Node);
removeNode(identifier: string);
valueAtPath(path: string): number;
setValueAtPath(path: string, ...);
addEdge(edge: Edge);
removeEdge(identifier: string);
constructor(json: string);
}A node tells the graph which plugins to execute.
class Node {
let identifier: string;
let type: string;
let isOutputNode: bool;
toJSON(): string;
constructor(identifier: string, type: string);
}An edge tells the graph how to connect two nodes.
class Edge {
let identifier: string;
let source: string;
let target: string;
toJSON(): string;
constructor(identifier: string, source: string, target: string);
}A script modifies the graph at runtime in response to messages.
class Script {
let name: string;
let scope: int;
close();
}