From ff85e1249de721707f626a352ad478e59efc8006 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Tue, 25 Aug 2015 13:52:08 -0400 Subject: [PATCH 1/3] handle error on flash tech better --- src/js/tech/flash.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/js/tech/flash.js b/src/js/tech/flash.js index f6dff2f4ff..c1b5b79497 100644 --- a/src/js/tech/flash.js +++ b/src/js/tech/flash.js @@ -267,6 +267,16 @@ class Flash extends Tech { return createTimeRange(0, this.el_.vjs_getProperty('buffered')); } + /** + * Get the last error object + * + * @return {Object} + * @method error + */ + error() { + return this.error_ || {}; + } + /** * Get fullscreen support - * Flash does not allow fullscreen through javascript @@ -297,7 +307,7 @@ class Flash extends Tech { // Create setters and getters for attributes const _api = Flash.prototype; const _readWrite = 'rtmpConnection,rtmpStream,preload,defaultPlaybackRate,playbackRate,autoplay,loop,mediaGroup,controller,controls,volume,muted,defaultMuted'.split(','); -const _readOnly = 'error,networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(','); +const _readOnly = 'networkState,readyState,initialTime,duration,startOffsetTime,paused,ended,videoTracks,audioTracks,videoWidth,videoHeight'.split(','); function _createSetter(attr){ var attrUpper = attr.charAt(0).toUpperCase() + attr.slice(1); @@ -438,13 +448,19 @@ Flash.onEvent = function(swfID, eventName){ Flash.onError = function(swfID, err){ const tech = Dom.getEl(swfID).tech; const msg = 'FLASH: '+err; + const errorObj = { + message: msg + }; + + tech.error_ = errorObj; if (err === 'srcnotfound') { - tech.trigger('error', { code: 4, message: msg }); + errorObj.code = 4; + tech.trigger('error', errorObj); // errors we haven't categorized into the media errors } else { - tech.trigger('error', msg); + tech.trigger('error', errorObj); } }; From ba4e911f3533abe17d9aa1bfd41f5beeca2c027a Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Tue, 25 Aug 2015 14:30:00 -0400 Subject: [PATCH 2/3] Simplify onError --- src/js/tech/flash.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/js/tech/flash.js b/src/js/tech/flash.js index c1b5b79497..be8d97c7db 100644 --- a/src/js/tech/flash.js +++ b/src/js/tech/flash.js @@ -456,12 +456,9 @@ Flash.onError = function(swfID, err){ if (err === 'srcnotfound') { errorObj.code = 4; - tech.trigger('error', errorObj); - - // errors we haven't categorized into the media errors - } else { - tech.trigger('error', errorObj); } + + tech.trigger('error', errorObj); }; // Flash Version Check From d663dbf46ac086c6766ce890a83bb77d7b085bdd Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Tue, 25 Aug 2015 14:43:56 -0400 Subject: [PATCH 3/3] Update error getter and tech error handler --- src/js/player.js | 3 ++- src/js/tech/flash.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/js/player.js b/src/js/player.js index b8b2ee155d..a7346e1d25 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -998,7 +998,8 @@ class Player extends Component { * @event error */ handleTechError() { - this.error(this.tech.error().code); + let error = this.tech.error(); + this.error(error && error.code); } /** diff --git a/src/js/tech/flash.js b/src/js/tech/flash.js index be8d97c7db..5c5f4273e1 100644 --- a/src/js/tech/flash.js +++ b/src/js/tech/flash.js @@ -274,7 +274,9 @@ class Flash extends Tech { * @method error */ error() { - return this.error_ || {}; + let error = this.error_; + this.error_ = null; + return error || null; } /**