docs/dist/videocontext.js
/**
	    * Initialise the VideoContext and render to the specific canvas. A 2nd parameter can be passed to the constructor which is a function that get's called if the VideoContext fails to initialise.
	    *
	    * @param {Canvas} canvas - the canvas element to render the output to.
	    * @param {function} initErrorCallback - a callback for if initialising the canvas failed.
	    * @param {Object} options - a nuber of custom options which can be set on the VideoContext, generally best left as default.
	    *
	    * @example
	    * var canvasElement = document.getElementById("canvas");
	    * var ctx = new VideoContext(canvasElement, function(){console.error("Sorry, your browser dosen\'t support WebGL");});
	    * var videoNode = ctx.video("video.mp4");
	    * videoNode.connect(ctx.destination);
	    * videoNode.start(0);
	    * videoNode.stop(10);
	    * ctx.play();
	    *
	    */
Initialise the VideoContext and render to the specific canvas. A 2nd parameter can be passed to the constructor which is a function that get's called if the VideoContext fails to initialise.
@param {Canvas} canvas - the canvas element to render the output to.
@param {function} initErrorCallback - a callback for if initialising the canvas failed.
@param {Object} options - a nuber of custom options which can be set on the VideoContext, generally best left as default.


Initialise the VideoContext and render to the specific canvas . A 2nd parameter can be passed to the constructor which is a function that get ' s called if the VideoContext fails to initialise . @param { Canvas } canvas - the canvas element to render the output to . @param { function } initErrorCallback - a callback for if initialising the canvas failed . @param { Object } options - a nuber of custom options which can be set on the VideoContext generally best left as default .
function VideoContext(canvas, initErrorCallback) {
	        var options = arguments.length <= 2 || arguments[2] === undefined ? { "preserveDrawingBuffer": true, "manualUpdate": false, "endOnLastSourceEnd": true, useVideoElementCache: true, videoElementCacheSize: 6, webglContextAttributes: { preserveDrawingBuffer: true, alpha: false } } : arguments[2];
	        _classCallCheck(this, VideoContext);
	        this._canvas = canvas;
	        var manualUpdate = false;
	        this.endOnLastSourceEnd = true;
	        var webglContextAttributes = { preserveDrawingBuffer: true, alpha: false };
	        if ("manualUpdate" in options) manualUpdate = options.manualUpdate;
	        if ("endOnLastSourceEnd" in options) this._endOnLastSourceEnd = options.endOnLastSourceEnd;
	        if ("webglContextAttributes" in options) webglContextAttributes = options.webglContextAttributes;
	        if (webglContextAttributes.alpha === undefined) webglContextAttributes.alpha = false;
	        if (webglContextAttributes.alpha === true) {
	            console.error("webglContextAttributes.alpha must be false for correct opeation");
	        }
	        this._gl = canvas.getContext("experimental-webgl", webglContextAttributes);
	        if (this._gl === null) {
	            console.error("Failed to intialise WebGL.");
	            if (initErrorCallback) initErrorCallback();
	            return;
	        }
	        if (options.useVideoElementCache === undefined) options.useVideoElementCache = true;
	        this._useVideoElementCache = options.useVideoElementCache;
	        if (this._useVideoElementCache) {
	            if (!options.videoElementCacheSize) options.videoElementCacheSize = 5;
	            this._videoElementCache = new _videoelementcacheJs2["default"](options.videoElementCacheSize);
	        }
	        if (this._canvas.id) {
	            if (typeof this._canvas.id === "string" || this._canvas.id instanceof String) {
	                this._id = canvas.id;
	            }
	        }
	        if (this._id === undefined) this._id = (0, _utilsJs.generateRandomId)();
	        if (window.__VIDEOCONTEXT_REFS__ === undefined) window.__VIDEOCONTEXT_REFS__ = {};
	        window.__VIDEOCONTEXT_REFS__[this._id] = this;
	        this._renderGraph = new _rendergraphJs2["default"]();
	        this._sourceNodes = [];
	        this._processingNodes = [];
	        this._timeline = [];
	        this._currentTime = 0;
	        this._state = VideoContext.STATE.PAUSED;
	        this._playbackRate = 1.0;
	        this._volume = 1.0;
	        this._sourcesPlaying = undefined;
	        this._destinationNode = new _DestinationNodeDestinationnodeJs2["default"](this._gl, this._renderGraph);
	        this._callbacks = new Map();
	        this._callbacks.set("stalled", []);
	        this._callbacks.set("update", []);
	        this._callbacks.set("ended", []);
	        this._callbacks.set("content", []);
	        this._callbacks.set("nocontent", []);
	        this._timelineCallbacks = [];
	        if (!manualUpdate) {
	            updateablesManager.register(this);
	        }
	    }
function VideoContext ( canvas , initErrorCallback ) { var options = arguments . length <= 2 || arguments [ 2 ] === undefined ? { "preserveDrawingBuffer" : true , "manualUpdate" : false , "endOnLastSourceEnd" : true , useVideoElementCache : true , videoElementCacheSize : 6 , webglContextAttributes : { preserveDrawingBuffer : true , alpha : false } } : arguments [ 2 ] ; _classCallCheck ( this , VideoContext ) ; this . _canvas = canvas ; var manualUpdate = false ; this . endOnLastSourceEnd = true ; var webglContextAttributes = { preserveDrawingBuffer : true , alpha : false } ; if ( "manualUpdate" in options ) manualUpdate = options . manualUpdate ; if ( "endOnLastSourceEnd" in options ) this . _endOnLastSourceEnd = options . endOnLastSourceEnd ; if ( "webglContextAttributes" in options ) webglContextAttributes = options . webglContextAttributes ; if ( webglContextAttributes . alpha === undefined ) webglContextAttributes . alpha = false ; if ( webglContextAttributes . alpha === true ) { console . error ( "webglContextAttributes.alpha must be false for correct opeation" ) ; } this . _gl = canvas . getContext ( "experimental-webgl" , webglContextAttributes ) ; if ( this . _gl === null ) { console . error ( "Failed to intialise WebGL." ) ; if ( initErrorCallback ) initErrorCallback ( ) ; return ; } if ( options . useVideoElementCache === undefined ) options . useVideoElementCache = true ; this . _useVideoElementCache = options . useVideoElementCache ; if ( this . _useVideoElementCache ) { if ( ! options . videoElementCacheSize ) options . videoElementCacheSize = 5 ; this . _videoElementCache = new _videoelementcacheJs2 [ "default" ] ( options . videoElementCacheSize ) ; } if ( this . _canvas . id ) { if ( typeof this . _canvas . id === "string" || this . _canvas . id instanceof String ) { this . _id = canvas . id ; } } if ( this . _id === undefined ) this . _id = ( 0 , _utilsJs . generateRandomId ) ( ) ; if ( window . __VIDEOCONTEXT_REFS__ === undefined ) window . __VIDEOCONTEXT_REFS__ = { } ; window . __VIDEOCONTEXT_REFS__ [ this . _id ] = this ; this . _renderGraph = new _rendergraphJs2 [ "default" ] ( ) ; this . _sourceNodes = [ ] ; this . _processingNodes = [ ] ; this . _timeline = [ ] ; this . _currentTime = 0 ; this . _state = VideoContext . STATE . PAUSED ; this . _playbackRate = 1.0 ; this . _volume = 1.0 ; this . _sourcesPlaying = undefined ; this . _destinationNode = new _DestinationNodeDestinationnodeJs2 [ "default" ] ( this . _gl , this . _renderGraph ) ; this . _callbacks = new Map ( ) ; this . _callbacks . set ( "stalled" , [ ] ) ; this . _callbacks . set ( "update" , [ ] ) ; this . _callbacks . set ( "ended" , [ ] ) ; this . _callbacks . set ( "content" , [ ] ) ; this . _callbacks . set ( "nocontent" , [ ] ) ; this . _timelineCallbacks = [ ] ; if ( ! manualUpdate ) { updateablesManager . register ( this ) ; } }
Initialise the VideoContext and render to the specific canvas.
Initialise the VideoContext and render to the specific canvas .
// Initialise the video element cache // Create a unique ID for this VideoContext which can be used in the debugger.