Class: SourceNode

SourceNode()

new SourceNode()

Initialise an instance of a SourceNode. This is the base class for other Nodes which generate media to be passed into the processing pipeline.

Source:

Members

duration

Returns the duration of the node on a timeline. If no start time is set will return undefiend, if no stop time is set will return Infinity.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(5);
videoNode.stop(10);
console.log(videoNode.duration); //will output 10

duration

Returns the duration of the node on a timeline. If no start time is set will return undefiend, if no stop time is set will return Infinity.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(5);
videoNode.stop(10);
console.log(videoNode.duration); //will output 10

element

Returns the underlying DOM element which represents this source node. Note: If a source node is created with a url rather than passing in an existing element then this will return undefined until the source node preloads the element.

Source:
Examples
//Accessing the Element on a VideoNode created via a URL
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(0);
videoNode.stop(5);
//When the node starts playing the element should exist so set it's volume to 0
videoNode.regsiterCallback("play", function(){videoNode.element.volume = 0;});
//Accessing the Element on a VideoNode created via an already existing element
var ctx = new VideoContext();
var videoElement = document.createElement("video");
var videoNode = ctx.createVideoSourceNode(videoElement);
videoNode.start(0);
videoNode.stop(5);
//The elemnt can be accessed any time because it's lifecycle is managed outside of the VideoContext
videoNode.element.volume = 0;

element

Returns the underlying DOM element which represents this source node. Note: If a source node is created with a url rather than passing in an existing element then this will return undefined until the source node preloads the element.

Source:
Examples
//Accessing the Element on a VideoNode created via a URL
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(0);
videoNode.stop(5);
//When the node starts playing the element should exist so set it's volume to 0
videoNode.regsiterCallback("play", function(){videoNode.element.volume = 0;});
//Accessing the Element on a VideoNode created via an already existing element
var ctx = new VideoContext();
var videoElement = document.createElement("video");
var videoNode = ctx.createVideoSourceNode(videoElement);
videoNode.start(0);
videoNode.stop(5);
//The elemnt can be accessed any time because it's lifecycle is managed outside of the VideoContext
videoNode.element.volume = 0;

state

Returns the state of the node. 0 - Waiting, start() has not been called on it yet. 1 - Sequenced, start() has been called but it is not playing yet. 2 - Playing, the node is playing. 3 - Paused, the node is paused. 4 - Ended, playback of the node has finished.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
console.log(videoNode.state); //will output 0 (for waiting)
videoNode.start(5);
console.log(videoNode.state); //will output 1 (for sequenced)
videoNode.stop(10);
ctx.play();
console.log(videoNode.state); //will output 2 (for playing)
ctx.paused();
console.log(videoNode.state); //will output 3 (for paused)

state

Returns the state of the node. 0 - Waiting, start() has not been called on it yet. 1 - Sequenced, start() has been called but it is not playing yet. 2 - Playing, the node is playing. 3 - Paused, the node is paused. 4 - Ended, playback of the node has finished.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
console.log(videoNode.state); //will output 0 (for waiting)
videoNode.start(5);
console.log(videoNode.state); //will output 1 (for sequenced)
videoNode.stop(10);
ctx.play();
console.log(videoNode.state); //will output 2 (for playing)
ctx.paused();
console.log(videoNode.state); //will output 3 (for paused)

Methods

clearTimelineState()

Clear any timeline state the node currently has, this puts the node in the "waiting" state, as if neither start nor stop had been called.

Source:

clearTimelineState()

Clear any timeline state the node currently has, this puts the node in the "waiting" state, as if neither start nor stop had been called.

Source:

destroy()

Destroy and clean-up the node.

Source:

destroy()

Destroy and clean-up the node.

Source:

registerCallback(type, func)

Register callbacks against one of these events: "load", "destroy", "seek", "pause", "play", "ended", "durationchange", "loaded", "error"

Parameters:
Name Type Description
type String

the type of event to register the callback against.

func function

the function to call.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});

registerCallback(type, func)

Register callbacks against one of these events: "load", "destroy", "seek", "pause", "play", "ended", "durationchange", "loaded", "error"

Parameters:
Name Type Description
type String

the type of event to register the callback against.

func function

the function to call.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});

start(time) → {boolean}

Start playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the VideoContext which to start playing, if negative will play as soon as possible.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

start(time) → {boolean}

Start playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the VideoContext which to start playing, if negative will play as soon as possible.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

startAt(time) → {boolean}

Start playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to start playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

startAt(time) → {boolean}

Start playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to start playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

stop(time) → {boolean}

Stop playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the video context which to stop playback.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

stop(time) → {boolean}

Stop playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the video context which to stop playback.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

stopAt(time) → {boolean}

Stop playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to stop playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

stopAt(time) → {boolean}

Stop playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to stop playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

unregisterCallback(funcopt)

Remove callback.

Parameters:
Name Type Attributes Description
func function <optional>

the callback to remove, if undefined will remove all callbacks for this node.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});
videoNode.unregisterCallback(); //remove all of the three callbacks.

unregisterCallback(funcopt)

Remove callback.

Parameters:
Name Type Attributes Description
func function <optional>

the callback to remove, if undefined will remove all callbacks for this node.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});
videoNode.unregisterCallback(); //remove all of the three callbacks.

SourceNode()

new SourceNode()

Initialise an instance of a SourceNode. This is the base class for other Nodes which generate media to be passed into the processing pipeline.

Source:

Members

duration

Returns the duration of the node on a timeline. If no start time is set will return undefiend, if no stop time is set will return Infinity.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(5);
videoNode.stop(10);
console.log(videoNode.duration); //will output 10

duration

Returns the duration of the node on a timeline. If no start time is set will return undefiend, if no stop time is set will return Infinity.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(5);
videoNode.stop(10);
console.log(videoNode.duration); //will output 10

element

Returns the underlying DOM element which represents this source node. Note: If a source node is created with a url rather than passing in an existing element then this will return undefined until the source node preloads the element.

Source:
Examples
//Accessing the Element on a VideoNode created via a URL
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(0);
videoNode.stop(5);
//When the node starts playing the element should exist so set it's volume to 0
videoNode.regsiterCallback("play", function(){videoNode.element.volume = 0;});
//Accessing the Element on a VideoNode created via an already existing element
var ctx = new VideoContext();
var videoElement = document.createElement("video");
var videoNode = ctx.createVideoSourceNode(videoElement);
videoNode.start(0);
videoNode.stop(5);
//The elemnt can be accessed any time because it's lifecycle is managed outside of the VideoContext
videoNode.element.volume = 0;

element

Returns the underlying DOM element which represents this source node. Note: If a source node is created with a url rather than passing in an existing element then this will return undefined until the source node preloads the element.

Source:
Examples
//Accessing the Element on a VideoNode created via a URL
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
videoNode.start(0);
videoNode.stop(5);
//When the node starts playing the element should exist so set it's volume to 0
videoNode.regsiterCallback("play", function(){videoNode.element.volume = 0;});
//Accessing the Element on a VideoNode created via an already existing element
var ctx = new VideoContext();
var videoElement = document.createElement("video");
var videoNode = ctx.createVideoSourceNode(videoElement);
videoNode.start(0);
videoNode.stop(5);
//The elemnt can be accessed any time because it's lifecycle is managed outside of the VideoContext
videoNode.element.volume = 0;

state

Returns the state of the node. 0 - Waiting, start() has not been called on it yet. 1 - Sequenced, start() has been called but it is not playing yet. 2 - Playing, the node is playing. 3 - Paused, the node is paused. 4 - Ended, playback of the node has finished.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
console.log(videoNode.state); //will output 0 (for waiting)
videoNode.start(5);
console.log(videoNode.state); //will output 1 (for sequenced)
videoNode.stop(10);
ctx.play();
console.log(videoNode.state); //will output 2 (for playing)
ctx.paused();
console.log(videoNode.state); //will output 3 (for paused)

state

Returns the state of the node. 0 - Waiting, start() has not been called on it yet. 1 - Sequenced, start() has been called but it is not playing yet. 2 - Playing, the node is playing. 3 - Paused, the node is paused. 4 - Ended, playback of the node has finished.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');
console.log(videoNode.state); //will output 0 (for waiting)
videoNode.start(5);
console.log(videoNode.state); //will output 1 (for sequenced)
videoNode.stop(10);
ctx.play();
console.log(videoNode.state); //will output 2 (for playing)
ctx.paused();
console.log(videoNode.state); //will output 3 (for paused)

Methods

clearTimelineState()

Clear any timeline state the node currently has, this puts the node in the "waiting" state, as if neither start nor stop had been called.

Source:

clearTimelineState()

Clear any timeline state the node currently has, this puts the node in the "waiting" state, as if neither start nor stop had been called.

Source:

destroy()

Destroy and clean-up the node.

Source:

destroy()

Destroy and clean-up the node.

Source:

registerCallback(type, func)

Register callbacks against one of these events: "load", "destroy", "seek", "pause", "play", "ended", "durationchange", "loaded", "error"

Parameters:
Name Type Description
type String

the type of event to register the callback against.

func function

the function to call.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});

registerCallback(type, func)

Register callbacks against one of these events: "load", "destroy", "seek", "pause", "play", "ended", "durationchange", "loaded", "error"

Parameters:
Name Type Description
type String

the type of event to register the callback against.

func function

the function to call.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});

start(time) → {boolean}

Start playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the VideoContext which to start playing, if negative will play as soon as possible.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

start(time) → {boolean}

Start playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the VideoContext which to start playing, if negative will play as soon as possible.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

startAt(time) → {boolean}

Start playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to start playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

startAt(time) → {boolean}

Start playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to start playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if it is already sequenced.

Type
boolean

stop(time) → {boolean}

Stop playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the video context which to stop playback.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

stop(time) → {boolean}

Stop playback at VideoContext.currentTime plus passed time. If passed time is negative, will play as soon as possible.

Parameters:
Name Type Description
time number

the time from the currentTime of the video context which to stop playback.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

stopAt(time) → {boolean}

Stop playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to stop playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

stopAt(time) → {boolean}

Stop playback at an absolute time ont the VideoContext's timeline.

Parameters:
Name Type Description
time number

the time on the VideoContexts timeline to stop playing.

Source:
Returns:

Will return true is seqeuncing has succeded, or false if the playback has already ended or if start hasn't been called yet, or if time is less than the start time.

Type
boolean

unregisterCallback(funcopt)

Remove callback.

Parameters:
Name Type Attributes Description
func function <optional>

the callback to remove, if undefined will remove all callbacks for this node.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});
videoNode.unregisterCallback(); //remove all of the three callbacks.

unregisterCallback(funcopt)

Remove callback.

Parameters:
Name Type Attributes Description
func function <optional>

the callback to remove, if undefined will remove all callbacks for this node.

Source:
Example
var ctx = new VideoContext();
var videoNode = ctx.createVideoSourceNode('video.mp4');

videoNode.registerCallback("load", function(){"video is loading"});
videoNode.registerCallback("play", function(){"video is playing"});
videoNode.registerCallback("ended", function(){"video has eneded"});
videoNode.unregisterCallback(); //remove all of the three callbacks.