videocontext
Version:
A WebGL & HTML5 graph based video composition library
108 lines (80 loc) • 3.64 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: SourceNodes/canvasnode.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: SourceNodes/canvasnode.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>//Matthew Shotton, R&D User Experience,© BBC 2015
import SourceNode, { SOURCENODESTATE } from "./sourcenode";
class CanvasNode extends SourceNode {
/**
* Initialise an instance of a CanvasNode.
* This should not be called directly, but created through a call to videoContext.createCanvasNode();
*/
constructor(canvas, gl, renderGraph, currentTime, preloadTime = 4){
super(canvas, gl, renderGraph, currentTime);
this._preloadTime = preloadTime;
this._displayName = "CanvasNode";
}
_load(){
super._load();
this._ready = true;
this._triggerCallbacks("loaded");
}
_destroy(){
super._destroy();
this._ready = false;
}
_seek(time){
super._seek(time);
if (this.state === SOURCENODESTATE.playing || this.state === SOURCENODESTATE.paused){
if (this._element === undefined) this._load();
this._ready = false;
}
if((this._state === SOURCENODESTATE.sequenced || this._state === SOURCENODESTATE.ended) && this._element !== undefined){
this._destroy();
}
}
_update(currentTime){
//if (!super._update(currentTime)) return false;
super._update(currentTime);
if (this._startTime - this._currentTime < this._preloadTime && this._state !== SOURCENODESTATE.waiting && this._state !== SOURCENODESTATE.ended)this._load();
if (this._state === SOURCENODESTATE.playing){
return true;
} else if (this._state === SOURCENODESTATE.paused){
return true;
}
else if (this._state === SOURCENODESTATE.ended && this._element !== undefined){
this._destroy();
return false;
}
}
}
export default CanvasNode;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-VideoContext.html">VideoContext</a></li></ul><h3>Classes</h3><ul><li><a href="CanvasNode.html">CanvasNode</a></li><li><a href="CompositingNode.html">CompositingNode</a></li><li><a href="DestinationNode.html">DestinationNode</a></li><li><a href="EffectNode.html">EffectNode</a></li><li><a href="GraphNode.html">GraphNode</a></li><li><a href="ImageNode.html">ImageNode</a></li><li><a href="module-VideoContext.html">VideoContext</a></li><li><a href="ProcessingNode.html">ProcessingNode</a></li><li><a href="RenderGraph.html">RenderGraph</a></li><li><a href="SourceNode.html">SourceNode</a></li><li><a href="TransitionNode.html">TransitionNode</a></li><li><a href="VideoNode.html">VideoNode</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a>
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>