added error handling for config and frame rendering
diff --git a/player/js/animation/AnimationItem.js b/player/js/animation/AnimationItem.js
index 69ee2e5..80fd8aa 100644
--- a/player/js/animation/AnimationItem.js
+++ b/player/js/animation/AnimationItem.js
@@ -191,23 +191,27 @@
if(!this.renderer){
return;
}
- this.animationData = animData;
- this.totalFrames = Math.floor(this.animationData.op - this.animationData.ip);
- this.renderer.configAnimation(animData);
- if(!animData.assets){
- animData.assets = [];
- }
+ try {
+ this.animationData = animData;
+ this.totalFrames = Math.floor(this.animationData.op - this.animationData.ip);
+ this.renderer.configAnimation(animData);
+ if(!animData.assets){
+ animData.assets = [];
+ }
- this.assets = this.animationData.assets;
- this.frameRate = this.animationData.fr;
- this.firstFrame = Math.round(this.animationData.ip);
- this.frameMult = this.animationData.fr / 1000;
- this.renderer.searchExtraCompositions(animData.assets);
- this.trigger('config_ready');
- this.preloadImages();
- this.loadSegments();
- this.updaFrameModifier();
- this.waitForFontsLoaded();
+ this.assets = this.animationData.assets;
+ this.frameRate = this.animationData.fr;
+ this.firstFrame = Math.round(this.animationData.ip);
+ this.frameMult = this.animationData.fr / 1000;
+ this.renderer.searchExtraCompositions(animData.assets);
+ this.trigger('config_ready');
+ this.preloadImages();
+ this.loadSegments();
+ this.updaFrameModifier();
+ this.waitForFontsLoaded();
+ } catch(error) {
+ this.triggerConfigError(error);
+ }
};
AnimationItem.prototype.waitForFontsLoaded = function(){
@@ -261,7 +265,11 @@
if(this.isLoaded === false){
return;
}
- this.renderer.renderFrame(this.currentFrame + this.firstFrame);
+ try {
+ this.renderer.renderFrame(this.currentFrame + this.firstFrame);
+ } catch(error) {
+ this.triggerRenderFrameError(error);
+ }
};
AnimationItem.prototype.play = function (name) {
@@ -567,3 +575,23 @@
this.onDestroy.call(this,new BMDestroyEvent(name,this));
}
};
+
+AnimationItem.prototype.triggerRenderFrameError = function(nativeError) {
+
+ var error = new BMRenderFrameErrorEvent(nativeError, this.currentFrame);
+ this.triggerEvent('error', error);
+
+ if (this.onError) {
+ this.onError.call(this, error);
+ }
+}
+
+AnimationItem.prototype.triggerConfigError = function(nativeError) {
+
+ var error = new BMConfigErrorEvent(nativeError, this.currentFrame);
+ this.triggerEvent('error', error);
+
+ if (this.onError) {
+ this.onError.call(this, error);
+ }
+}
\ No newline at end of file
diff --git a/player/js/utils/PropertyFactory.js b/player/js/utils/PropertyFactory.js
index 90c25ec..a1b500f 100644
--- a/player/js/utils/PropertyFactory.js
+++ b/player/js/utils/PropertyFactory.js
@@ -269,9 +269,9 @@
}
function processEffectsSequence() {
- if(this.elem.globalData.frameId === this.frameId || !this.effectsSequence.length) {
+ if (this.elem.globalData.frameId === this.frameId || !this.effectsSequence.length) {
return;
- }
+ }
if(this.lock) {
this.setVValue(this.pv);
return;
diff --git a/player/js/utils/common.js b/player/js/utils/common.js
index bc3409c..3f40da1 100644
--- a/player/js/utils/common.js
+++ b/player/js/utils/common.js
@@ -62,34 +62,51 @@
element.style.transformStyle = element.style.webkitTransformStyle = element.style.mozTransformStyle = "preserve-3d";
}
-function BMEnterFrameEvent(n,c,t,d){
- this.type = n;
- this.currentTime = c;
- this.totalTime = t;
- this.direction = d < 0 ? -1:1;
+function BMEnterFrameEvent(type, currentTime, totalTime, frameMultiplier){
+ this.type = type;
+ this.currentTime = currentTime;
+ this.totalTime = totalTime;
+ this.direction = frameMultiplier < 0 ? -1 : 1;
}
-function BMCompleteEvent(n,d){
- this.type = n;
- this.direction = d < 0 ? -1:1;
+function BMCompleteEvent(type, frameMultiplier){
+ this.type = type;
+ this.direction = frameMultiplier < 0 ? -1 : 1;
}
-function BMCompleteLoopEvent(n,c,t,d){
- this.type = n;
- this.currentLoop = t;
- this.totalLoops = c;
- this.direction = d < 0 ? -1:1;
+function BMCompleteLoopEvent(type, totalLoops, currentLoop, frameMultiplier){
+ this.type = type;
+ this.currentLoop = currentLoop;
+ this.totalLoops = totalLoops;
+ this.direction = frameMultiplier < 0 ? -1 : 1;
}
-function BMSegmentStartEvent(n,f,t){
- this.type = n;
- this.firstFrame = f;
- this.totalFrames = t;
+function BMSegmentStartEvent(type, firstFrame, totalFrames){
+ this.type = type;
+ this.firstFrame = firstFrame;
+ this.totalFrames = totalFrames;
}
-function BMDestroyEvent(n,t){
- this.type = n;
- this.target = t;
+function BMDestroyEvent(type, target){
+ this.type = type;
+ this.target = target;
+}
+
+function BMRenderFrameErrorEvent(nativeError, currentTime) {
+ this.type = 'renderFrameError';
+ this.nativeError = nativeError;
+ this.currentTime = currentTime;
+}
+
+function BMConfigErrorEvent(nativeError) {
+ this.type = 'configError';
+ this.nativeError = nativeError;
+}
+
+function BMAnimationConfigErrorEvent(type, nativeError) {
+ this.type = type;
+ this.nativeError = nativeError;
+ this.currentTime = currentTime;
}
var createElementID = (function(){