videocontext
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"name": "videocontext", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "A WebGL & HTML5 graph based video composition library", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -31,10 +31,2 @@ //Matthew Shotton, R&D User Experience,© BBC 2015 | ||
let STATE = {"playing":0, "paused":1, "stalled":2, "ended":3, "broken":4}; | ||
//playing - all sources are active | ||
//paused - all sources are paused | ||
//stalled - one or more sources is unable to play | ||
//ended - all sources have finished playing | ||
//broken - the render graph is in a broken state | ||
export default class VideoContext{ | ||
@@ -46,3 +38,3 @@ /** | ||
* var canvasElement = document.getElemenyById("canvas"); | ||
* var ctx = new VideoContext(canvasElement, function(){console.error("Sorry, your browser dosen\'t support WebGL");}); | ||
* var ctx = new VideoContext(cgit pull https://github.com/tjenkinson/VideoContext.git patch-2anvasElement, function(){console.error("Sorry, your browser dosen\'t support WebGL");}); | ||
* var videoNode = ctx.createVideoSourceNode("video.mp4"); | ||
@@ -69,3 +61,3 @@ * videoNode.connect(ctx.destination); | ||
this._currentTime = 0; | ||
this._state = STATE.paused; | ||
this._state = VideoContext.STATE.PAUSED; | ||
this._playbackRate = 1.0; | ||
@@ -169,4 +161,30 @@ this._destinationNode = new DestinationNode(this._gl, this._renderGraph); | ||
} | ||
/** | ||
* Get the canvas that the VideoContext is using. | ||
* | ||
* @return {HTMLElement} The canvas that the VideoContext is using. | ||
* | ||
*/ | ||
get canvas(){ | ||
return this._canvas; | ||
} | ||
/** | ||
* Get the current state. | ||
* | ||
* This will be either | ||
* - VideoContext.STATE.PLAYING: all sources are active | ||
* - VideoContext.STATE.PAUSED: all sources are paused | ||
* - VideoContext.STATE.STALLED: one or more sources is unable to play | ||
* - VideoContext.STATE.ENDED: all sources have finished playing | ||
* - VideoContext.STATE.BROKEN: the render graph is in a broken state | ||
* @return {number} The number representing the state. | ||
* | ||
*/ | ||
get state(){ | ||
return this._state; | ||
} | ||
/** | ||
* Set the progress through the internal timeline. | ||
@@ -190,3 +208,3 @@ * Setting this can be used as a way to implement a scrubaable timeline. | ||
console.debug("VideoContext - seeking to", currentTime); | ||
if (currentTime < this._duration && this._state === STATE.ended) this._state = STATE.duration; | ||
if (currentTime < this._duration && this._state === VideoContext.STATE.ENDED) this._state = VideoContext.STATE.PAUSED; | ||
if (typeof currentTime === 'string' || currentTime instanceof String){ | ||
@@ -318,3 +336,3 @@ currentTime = parseFloat(currentTime); | ||
console.debug("VideoContext - playing"); | ||
this._state = STATE.playing; | ||
this._state = VideoContext.STATE.PLAYING; | ||
return true; | ||
@@ -338,3 +356,3 @@ } | ||
console.debug("VideoContext - pausing"); | ||
this._state = STATE.paused; | ||
this._state = VideoContext.STATE.PAUSED; | ||
return true; | ||
@@ -573,15 +591,15 @@ } | ||
_update(dt){ | ||
if (this._state === STATE.playing || this._state === STATE.stalled || this._state === STATE.paused) { | ||
if (this._state === VideoContext.STATE.PLAYING || this._state === VideoContext.STATE.STALLED || this._state === VideoContext.STATE.PAUSED) { | ||
this._callCallbacks("update"); | ||
if (this._state !== STATE.paused){ | ||
if (this._state !== VideoContext.STATE.PAUSED){ | ||
if (this._isStalled()){ | ||
this._callCallbacks("stalled"); | ||
this._state = STATE.stalled; | ||
this._state = VideoContext.STATE.STALLED; | ||
}else{ | ||
this._state = STATE.playing; | ||
this._state = VideoContext.STATE.PLAYING; | ||
} | ||
} | ||
if(this._state === STATE.playing){ | ||
if(this._state === VideoContext.STATE.PLAYING){ | ||
//Handle timeline callbacks. | ||
@@ -625,3 +643,3 @@ let activeCallbacks = new Map(); | ||
this._callCallbacks("ended"); | ||
this._state = STATE.ended; | ||
this._state = VideoContext.STATE.ENDED; | ||
} | ||
@@ -634,9 +652,9 @@ } | ||
if(this._state === STATE.stalled){ | ||
if(this._state === VideoContext.STATE.STALLED){ | ||
if (sourceNode._isReady() && sourceNode._state === SOURCENODESTATE.playing) sourceNode._pause(); | ||
} | ||
if(this._state === STATE.paused){ | ||
if(this._state === VideoContext.STATE.PAUSED){ | ||
if (sourceNode._state === SOURCENODESTATE.playing)sourceNode._pause(); | ||
} | ||
if(this._state === STATE.playing){ | ||
if(this._state === VideoContext.STATE.PLAYING){ | ||
if (sourceNode._state === SOURCENODESTATE.paused)sourceNode._play(); | ||
@@ -1147,2 +1165,15 @@ } | ||
//playing - all sources are active | ||
//paused - all sources are paused | ||
//stalled - one or more sources is unable to play | ||
//ended - all sources have finished playing | ||
//broken - the render graph is in a broken state | ||
VideoContext.STATE = {}; | ||
VideoContext.STATE.PLAYING = 0; | ||
VideoContext.STATE.PAUSED = 1; | ||
VideoContext.STATE.STALLED = 2; | ||
VideoContext.STATE.ENDED = 3; | ||
VideoContext.STATE.BROKEN = 4; | ||
VideoContext.visualiseVideoContextTimeline = visualiseVideoContextTimeline; | ||
@@ -1149,0 +1180,0 @@ VideoContext.visualiseVideoContextGraph = visualiseVideoContextGraph; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8704812
192877