Home Reference Source
public class | source

SourceNode

Extends:

GraphNode → SourceNode

Direct Subclass:

CanvasNode, ImageNode, MediaNode

Indirect Subclass:

AudioNode, VideoNode

Constructor Summary

Public Constructor
public

Initialise an instance of a SourceNode.

Member Summary

Public Members
public get

Returns the duration of the node on a timeline.

public get

element: Element: *

Returns the underlying DOM element which represents this source node.

public get
public get

state: *

Returns the state of the node.

public get
public set
public get
Private Members
private

_callbacks: *[]

private
private
private
private
private
private
private
private
private
private
private

_state: *

private
private
private

Method Summary

Public Methods
public

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.

public

Destroy and clean-up the node.

public

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

public

start(time: number): boolean

Start playback at VideoContext.currentTime plus passed time.

public

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

public

stop(time: number): boolean

Stop playback at VideoContext.currentTime plus passed time.

public

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

public

Remove callback.

Private Methods
private
private

_load()

private

_pause()

private

_play()

private

_seek(time: *)

private

_triggerCallbacks(type: *, data: *)

private
private

_update(currentTime: *, triggerTextureUpdate: boolean): boolean

Inherited Summary

From class GraphNode
public get

Get whether the node has been destroyed or not.

public get

displayName: *: *

Get a string representation of the class name.

public get

Get the names of the inputs to this node.

public get

Get an array of all the nodes which connect to this node.

public get

The maximum number of connections that can be made to this node.

public get

Get an array of all the nodes which this node outputs to.

private
private
private

_gl: *

private
private
private
private
public

connect(targetNode: GraphNode, targetPort: number | String): *

Connect this node to the targetNode

public

Destory this node, removing it from the graph.

public

disconnect(targetNode: GraphNode): *

Disconnect this node from the targetNode.

Public Constructors

public constructor() source

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

Override:

GraphNode#constructor

Public Members

public get duration: number: * source

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.

Return:

number

The duration of the node in seconds.

Example:

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

public get element: Element: * source

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.

Return:

Element

The underlying DOM element representing the media for the node. If the lifecycle of the video is owned UNSIGNED_BYTE the node itself, this can return undefined if the element hasn't been loaded yet.

Example:

//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;

public get startTime: * source

public get state: * source

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.

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)

public get stopTime: * source

public set stretchPaused source

public get stretchPaused: * source

Private Members

private _callbacks: *[] source

private _currentTime: * source

private _displayName: string source

Override:

GraphNode#_displayName

private _element: * source

private _elementURL: * source

private _isResponsibleForElementLifeCycle: boolean source

private _loadCalled: boolean source

private _ready: boolean source

private _renderPaused: boolean source

private _rendered: boolean source

Override:

GraphNode#_rendered

private _startTime: * source

private _state: * source

private _stopTime: * source

private _stretchPaused: boolean source

private _texture: * source

Public Methods

public clearTimelineState() source

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.

public destroy() source

Destroy and clean-up the node.

Override:

GraphNode#destroy

public registerCallback(type: String, func: function) source

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

Params:

NameTypeAttributeDescription
type String

the type of event to register the callback against.

func function

the function to call.

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"});

public start(time: number): boolean source

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

Params:

NameTypeAttributeDescription
time number

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

Return:

boolean

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

public startAt(time: number): boolean source

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

Params:

NameTypeAttributeDescription
time number

the time on the VideoContexts timeline to start playing.

Return:

boolean

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

public stop(time: number): boolean source

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

Params:

NameTypeAttributeDescription
time number

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

Return:

boolean

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.

public stopAt(time: number): boolean source

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

Params:

NameTypeAttributeDescription
time number

the time on the VideoContexts timeline to stop playing.

Return:

boolean

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.

public unregisterCallback(func: function) source

Remove callback.

Params:

NameTypeAttributeDescription
func function
  • optional

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

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.

Private Methods

private _isReady(): boolean source

Return:

boolean

private _load() source

private _pause() source

private _play() source

private _seek(time: *) source

Params:

NameTypeAttributeDescription
time *

private _triggerCallbacks(type: *, data: *) source

Params:

NameTypeAttributeDescription
type *
data *

private _unload() source

private _update(currentTime: *, triggerTextureUpdate: boolean): boolean source

Params:

NameTypeAttributeDescription
currentTime *
triggerTextureUpdate boolean
  • optional
  • default: true

Return:

boolean