videojs-errors
Advanced tools
Comparing version 4.4.0 to 4.5.0
@@ -0,1 +1,8 @@ | ||
<a name="4.5.0"></a> | ||
# [4.5.0](https://github.com/brightcove/videojs-errors/compare/v4.4.0...v4.5.0) (2021-05-04) | ||
### Features | ||
* add support for -1 timeout and backgroundTimeout values ([#206](https://github.com/brightcove/videojs-errors/issues/206)) ([cf0ea56](https://github.com/brightcove/videojs-errors/commit/cf0ea56)) | ||
<a name="4.4.0"></a> | ||
@@ -2,0 +9,0 @@ # [4.4.0](https://github.com/brightcove/videojs-errors/compare/v4.3.2...v4.4.0) (2021-04-13) |
@@ -1,2 +0,2 @@ | ||
/*! @name videojs-errors @version 4.4.0 @license Apache-2.0 */ | ||
/*! @name videojs-errors @version 4.5.0 @license Apache-2.0 */ | ||
'use strict'; | ||
@@ -9,3 +9,3 @@ | ||
var version = "4.4.0"; | ||
var version = "4.5.0"; | ||
@@ -110,3 +110,9 @@ var FlashObj = videojs.getComponent('Flash'); | ||
if (document.visibilityState === 'hidden' && (options.backgroundTimeout === Infinity || player.muted()) || document.visibilityState === 'visible' && options.timeout === Infinity) { | ||
var disableValues = [Infinity, -1]; | ||
var disableValueMatch = function disableValueMatch(valArray, option) { | ||
return valArray.indexOf(option) !== -1; | ||
}; | ||
if (document.visibilityState === 'hidden' && (player.muted() || disableValueMatch(disableValues, options.backgroundTimeout)) || document.visibilityState === 'visible' && disableValueMatch(disableValues, options.timeout)) { | ||
return; | ||
@@ -113,0 +119,0 @@ } // start the loading spinner if player has stalled |
@@ -1,6 +0,6 @@ | ||
/*! @name videojs-errors @version 4.4.0 @license Apache-2.0 */ | ||
/*! @name videojs-errors @version 4.5.0 @license Apache-2.0 */ | ||
import videojs from 'video.js'; | ||
import document from 'global/document'; | ||
var version = "4.4.0"; | ||
var version = "4.5.0"; | ||
@@ -105,3 +105,9 @@ var FlashObj = videojs.getComponent('Flash'); | ||
if (document.visibilityState === 'hidden' && (options.backgroundTimeout === Infinity || player.muted()) || document.visibilityState === 'visible' && options.timeout === Infinity) { | ||
var disableValues = [Infinity, -1]; | ||
var disableValueMatch = function disableValueMatch(valArray, option) { | ||
return valArray.indexOf(option) !== -1; | ||
}; | ||
if (document.visibilityState === 'hidden' && (player.muted() || disableValueMatch(disableValues, options.backgroundTimeout)) || document.visibilityState === 'visible' && disableValueMatch(disableValues, options.timeout)) { | ||
return; | ||
@@ -108,0 +114,0 @@ } // start the loading spinner if player has stalled |
@@ -1,2 +0,2 @@ | ||
/*! @name videojs-errors @version 4.4.0 @license Apache-2.0 */ | ||
/*! @name videojs-errors @version 4.5.0 @license Apache-2.0 */ | ||
(function (global, factory) { | ||
@@ -11,3 +11,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js'), require('global/document')) : | ||
var version = "4.4.0"; | ||
var version = "4.5.0"; | ||
@@ -112,3 +112,9 @@ var FlashObj = videojs.getComponent('Flash'); | ||
if (document.visibilityState === 'hidden' && (options.backgroundTimeout === Infinity || player.muted()) || document.visibilityState === 'visible' && options.timeout === Infinity) { | ||
var disableValues = [Infinity, -1]; | ||
var disableValueMatch = function disableValueMatch(valArray, option) { | ||
return valArray.indexOf(option) !== -1; | ||
}; | ||
if (document.visibilityState === 'hidden' && (player.muted() || disableValueMatch(disableValues, options.backgroundTimeout)) || document.visibilityState === 'visible' && disableValueMatch(disableValues, options.timeout)) { | ||
return; | ||
@@ -115,0 +121,0 @@ } // start the loading spinner if player has stalled |
@@ -1,2 +0,2 @@ | ||
/*! @name videojs-errors @version 4.4.0 @license Apache-2.0 */ | ||
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("video.js"),require("global/document")):"function"==typeof define&&define.amd?define(["video.js","global/document"],o):(e=e||self).videojsErrors=o(e.videojs,e.document)}(this,(function(e,o){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,o=o&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o;var r=e.getComponent("Flash"),i=!e.browser.IS_IPHONE,t=e.registerPlugin||e.plugin,n={header:"",code:"",message:"",timeout:45e3,backgroundTimeout:3e5,dismiss:i,errors:{1:{type:"MEDIA_ERR_ABORTED",headline:"The video download was cancelled"},2:{type:"MEDIA_ERR_NETWORK",headline:"The video connection was lost, please confirm you are connected to the internet"},3:{type:"MEDIA_ERR_DECODE",headline:"The video is bad or in a format that cannot be played on your browser"},4:{type:"MEDIA_ERR_SRC_NOT_SUPPORTED",headline:"This video is either unavailable or not supported in this browser"},5:{type:"MEDIA_ERR_ENCRYPTED",headline:"The video you are trying to watch is encrypted and we do not know how to decrypt it"},unknown:{type:"MEDIA_ERR_UNKNOWN",headline:"An unanticipated problem was encountered, check back soon and try again"},"-1":{type:"PLAYER_ERR_NO_SRC",headline:"No video has been loaded"},"-2":{type:"PLAYER_ERR_TIMEOUT",headline:"Could not download the video"},PLAYER_ERR_DOMAIN_RESTRICTED:{headline:"This video is restricted from playing on your current domain"},PLAYER_ERR_IP_RESTRICTED:{headline:"This video is restricted at your current IP address"},PLAYER_ERR_GEO_RESTRICTED:{headline:"This video is restricted from playing in your current geographic region"},FLASHLS_ERR_CROSS_DOMAIN:{headline:"The video could not be loaded: crossdomain access denied."}}},s=function i(t,s){var a,d,l,c=[],u=function(o){s.errors=e.mergeOptions(s.errors,o),Object.keys(s.errors).forEach((function(e){var o=s.errors[e];o.type||(o.type=e)}))};u();var f=function(){t.error()&&-2===t.error().code&&t.error(null),t.clearTimeout(d),t.clearTimeout(a),l&&(l=!1,t.removeClass("vjs-waiting")),"hidden"===o.visibilityState&&(s.backgroundTimeout===1/0||t.muted())||"visible"===o.visibilityState&&s.timeout===1/0||(d=t.setTimeout((function(){t.error()||t.paused()||t.ended()||(l=!0,t.addClass("vjs-waiting"))}),1e3),a=t.setTimeout((function(){t.error()||t.paused()||t.ended()||t.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})}),"hidden"===o.visibilityState?s.backgroundTimeout:s.timeout))},h=function(){for(var e;c.length;)e=c.shift(),t.off(e[0],e[1]);t.clearTimeout(a),t.clearTimeout(d)},p=function e(){var r,i,n,s=0;h(),f(),r=["timeupdate","adtimeupdate"],i=function(){var e=t.currentTime();e!==s&&(s=e,f())},n=function(){if(!t.error()){var e=t.$(".vjs-tech");if(e&&"application/x-shockwave-flash"===e.type&&!e.vjs_getProperty)return void t.error({code:-2,type:"PLAYER_ERR_TIMEOUT"});if(t.paused())return f();if(t.ended())return f()}i.call(this)},t.on(r,n),c.push([r,n]),t.off(o,"visibilitychange",e),t.on(o,"visibilitychange",e)},v=function(){t.currentSrc()||t.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},m=function(){var i="",n=t.error(),a=o.createElement("div"),d="";if(n){if(t.off(o,"visibilitychange",p),(n=e.mergeOptions(n,s.errors[n.code||n.type||0])).message&&(i='<div class="vjs-errors-details">'+t.localize("Technical details")+'\n : <div class="vjs-errors-message">'+t.localize(n.message)+"</div>\n </div>"),4===n.code&&r&&!r.isSupported())i+='<span class="vjs-errors-flashmessage">'+t.localize("If you are using an older browser please try upgrading or installing Flash.")+"</span>";var l=t.getChild("errorDisplay");if(a.className="vjs-errors-dialog",a.id="vjs-errors-dialog",d='<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">'+this.localize(n.headline)+'</h2>\n <div class="vjs-errors-code"><b>'+this.localize("Error Code")+":</b> "+(n.type||n.code)+"</div>\n "+i+"\n </div>",l.closeable(!("dismiss"in n)||n.dismiss)){d+='<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">'+this.localize("OK")+"</button>\n </div>",a.innerHTML=d,l.fillWith(a),l.contentEl().firstChild.appendChild(l.getChild("closeButton").el());var c=l.el().querySelector(".vjs-errors-ok-button");t.on(c,"click",(function(){l.close()}))}else a.innerHTML=d,l.fillWith(a);(t.currentWidth()<=600||t.currentHeight()<=250)&&l.addClass("vjs-xs"),l.one("modalclose",(function(){return t.error(null)}))}},E=function e(){h(),t.removeClass("vjs-errors"),t.off("play",p),t.off(o,"visibilitychange",p),t.off("play",v),t.off("dispose",e),t.off(["aderror","error"],m)},y=function(o){E(),i(t,e.mergeOptions(n,o))};y.extend=function(e){return u(e)},y.getAll=function(){return e.mergeOptions(s.errors)},y.timeout=function(e){if(void 0===e)return s.timeout;e!==s.timeout&&(s.timeout=e,t.paused()||p())},y.backgroundTimeout=function(e){if(void 0===e)return s.backgroundTimeout;e!==s.backgroundTimeout&&(s.backgroundTimeout=e,t.paused()||p())},y.disableProgress=function(){},t.on("play",p),t.on("play",v),t.on("dispose",E),t.on(["aderror","contenterror","error"],m),t.ready((function(){t.addClass("vjs-errors")})),t.paused()||p(),y.VERSION="4.4.0",t.errors=y},a=function(o){s(this,e.mergeOptions(n,o))};return["extend","getAll"].forEach((function(o){a[o]=function(){e.log.warn("The errors."+o+"() method is not available until the plugin has been initialized!")}})),a.VERSION="4.4.0",t("errors",a),a})); | ||
/*! @name videojs-errors @version 4.5.0 @license Apache-2.0 */ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("video.js"),require("global/document")):"function"==typeof define&&define.amd?define(["video.js","global/document"],r):(e=e||self).videojsErrors=r(e.videojs,e.document)}(this,(function(e,r){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var o=e.getComponent("Flash"),i=!e.browser.IS_IPHONE,t=e.registerPlugin||e.plugin,n={header:"",code:"",message:"",timeout:45e3,backgroundTimeout:3e5,dismiss:i,errors:{1:{type:"MEDIA_ERR_ABORTED",headline:"The video download was cancelled"},2:{type:"MEDIA_ERR_NETWORK",headline:"The video connection was lost, please confirm you are connected to the internet"},3:{type:"MEDIA_ERR_DECODE",headline:"The video is bad or in a format that cannot be played on your browser"},4:{type:"MEDIA_ERR_SRC_NOT_SUPPORTED",headline:"This video is either unavailable or not supported in this browser"},5:{type:"MEDIA_ERR_ENCRYPTED",headline:"The video you are trying to watch is encrypted and we do not know how to decrypt it"},unknown:{type:"MEDIA_ERR_UNKNOWN",headline:"An unanticipated problem was encountered, check back soon and try again"},"-1":{type:"PLAYER_ERR_NO_SRC",headline:"No video has been loaded"},"-2":{type:"PLAYER_ERR_TIMEOUT",headline:"Could not download the video"},PLAYER_ERR_DOMAIN_RESTRICTED:{headline:"This video is restricted from playing on your current domain"},PLAYER_ERR_IP_RESTRICTED:{headline:"This video is restricted at your current IP address"},PLAYER_ERR_GEO_RESTRICTED:{headline:"This video is restricted from playing in your current geographic region"},FLASHLS_ERR_CROSS_DOMAIN:{headline:"The video could not be loaded: crossdomain access denied."}}},s=function i(t,s){var a,d,l,c=[],u=function(r){s.errors=e.mergeOptions(s.errors,r),Object.keys(s.errors).forEach((function(e){var r=s.errors[e];r.type||(r.type=e)}))};u();var f=function(){t.error()&&-2===t.error().code&&t.error(null),t.clearTimeout(d),t.clearTimeout(a),l&&(l=!1,t.removeClass("vjs-waiting"));var e=[1/0,-1],o=function(e,r){return-1!==e.indexOf(r)};"hidden"===r.visibilityState&&(t.muted()||o(e,s.backgroundTimeout))||"visible"===r.visibilityState&&o(e,s.timeout)||(d=t.setTimeout((function(){t.error()||t.paused()||t.ended()||(l=!0,t.addClass("vjs-waiting"))}),1e3),a=t.setTimeout((function(){t.error()||t.paused()||t.ended()||t.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})}),"hidden"===r.visibilityState?s.backgroundTimeout:s.timeout))},h=function(){for(var e;c.length;)e=c.shift(),t.off(e[0],e[1]);t.clearTimeout(a),t.clearTimeout(d)},p=function e(){var o,i,n,s=0;h(),f(),o=["timeupdate","adtimeupdate"],i=function(){var e=t.currentTime();e!==s&&(s=e,f())},n=function(){if(!t.error()){var e=t.$(".vjs-tech");if(e&&"application/x-shockwave-flash"===e.type&&!e.vjs_getProperty)return void t.error({code:-2,type:"PLAYER_ERR_TIMEOUT"});if(t.paused())return f();if(t.ended())return f()}i.call(this)},t.on(o,n),c.push([o,n]),t.off(r,"visibilitychange",e),t.on(r,"visibilitychange",e)},v=function(){t.currentSrc()||t.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},m=function(){var i="",n=t.error(),a=r.createElement("div"),d="";if(n){if(t.off(r,"visibilitychange",p),(n=e.mergeOptions(n,s.errors[n.code||n.type||0])).message&&(i='<div class="vjs-errors-details">'+t.localize("Technical details")+'\n : <div class="vjs-errors-message">'+t.localize(n.message)+"</div>\n </div>"),4===n.code&&o&&!o.isSupported())i+='<span class="vjs-errors-flashmessage">'+t.localize("If you are using an older browser please try upgrading or installing Flash.")+"</span>";var l=t.getChild("errorDisplay");if(a.className="vjs-errors-dialog",a.id="vjs-errors-dialog",d='<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">'+this.localize(n.headline)+'</h2>\n <div class="vjs-errors-code"><b>'+this.localize("Error Code")+":</b> "+(n.type||n.code)+"</div>\n "+i+"\n </div>",l.closeable(!("dismiss"in n)||n.dismiss)){d+='<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">'+this.localize("OK")+"</button>\n </div>",a.innerHTML=d,l.fillWith(a),l.contentEl().firstChild.appendChild(l.getChild("closeButton").el());var c=l.el().querySelector(".vjs-errors-ok-button");t.on(c,"click",(function(){l.close()}))}else a.innerHTML=d,l.fillWith(a);(t.currentWidth()<=600||t.currentHeight()<=250)&&l.addClass("vjs-xs"),l.one("modalclose",(function(){return t.error(null)}))}},E=function e(){h(),t.removeClass("vjs-errors"),t.off("play",p),t.off(r,"visibilitychange",p),t.off("play",v),t.off("dispose",e),t.off(["aderror","error"],m)},y=function(r){E(),i(t,e.mergeOptions(n,r))};y.extend=function(e){return u(e)},y.getAll=function(){return e.mergeOptions(s.errors)},y.timeout=function(e){if(void 0===e)return s.timeout;e!==s.timeout&&(s.timeout=e,t.paused()||p())},y.backgroundTimeout=function(e){if(void 0===e)return s.backgroundTimeout;e!==s.backgroundTimeout&&(s.backgroundTimeout=e,t.paused()||p())},y.disableProgress=function(){},t.on("play",p),t.on("play",v),t.on("dispose",E),t.on(["aderror","contenterror","error"],m),t.ready((function(){t.addClass("vjs-errors")})),t.paused()||p(),y.VERSION="4.5.0",t.errors=y},a=function(r){s(this,e.mergeOptions(n,r))};return["extend","getAll"].forEach((function(r){a[r]=function(){e.log.warn("The errors."+r+"() method is not available until the plugin has been initialized!")}})),a.VERSION="4.5.0",t("errors",a),a})); |
{ | ||
"name": "videojs-errors", | ||
"version": "4.4.0", | ||
"version": "4.5.0", | ||
"author": "Brightcove, Inc.", | ||
@@ -5,0 +5,0 @@ "description": "A Video.js plugin for custom error reporting", |
@@ -176,3 +176,3 @@ # videojs-errors | ||
Setting the timeout to `Infinity` will turn off this check. | ||
Setting the timeout to `Infinity` or `-1` will turn off this check. | ||
@@ -179,0 +179,0 @@ If no argument is passed, the current timeout value is returned. |
@@ -110,5 +110,8 @@ import videojs from 'video.js'; | ||
// 1 minute in that case | ||
const disableValues = [Infinity, -1]; | ||
const disableValueMatch = (valArray, option) => valArray.indexOf(option) !== -1; | ||
if ((document.visibilityState === 'hidden' && | ||
(options.backgroundTimeout === Infinity || player.muted())) || | ||
(document.visibilityState === 'visible' && options.timeout === Infinity)) { | ||
(player.muted() || disableValueMatch(disableValues, options.backgroundTimeout))) || | ||
(document.visibilityState === 'visible' && disableValueMatch(disableValues, options.timeout))) { | ||
return; | ||
@@ -115,0 +118,0 @@ } |
@@ -324,2 +324,35 @@ import document from 'global/document'; | ||
QUnit.test('timeout is disabled in background if backgroundTimeout option === -1', function(assert) { | ||
let errors = 0; | ||
// Init with custom option | ||
this.player.errors({backgroundTimeout: -1}); | ||
this.player.on('error', function() { | ||
errors++; | ||
}); | ||
this.player.src(sources); | ||
this.player.trigger('play'); | ||
this.clock.tick(1 * 1000); | ||
assert.ok( | ||
this.player.hasClass('vjs-waiting'), | ||
'the plugin adds spinner class to the player after 1 sec of no progress' | ||
); | ||
// document becomes hidden | ||
document.visibilityState = 'hidden'; | ||
Events.trigger(document, 'visibilitychange'); | ||
this.clock.tick(300 * 1000); | ||
assert.strictEqual(errors, 0, 'did not emit an error in background after 5 minutes'); | ||
this.clock.tick(300 * 1000); | ||
assert.strictEqual(errors, 0, 'still did not emit an error in background after another 5 minutes'); | ||
}); | ||
QUnit.test('timeout is disabled in background if the player is muted', function(assert) { | ||
@@ -385,2 +418,34 @@ let errors = 0; | ||
QUnit.test('timeout is disabled in foreground if timeout option === -1', function(assert) { | ||
let errors = 0; | ||
// Init with custom option | ||
this.player.errors({timeout: -1}); | ||
this.player.on('error', function() { | ||
errors++; | ||
}); | ||
this.player.src(sources); | ||
this.player.trigger('play'); | ||
this.clock.tick(1 * 1000); | ||
assert.notOk( | ||
this.player.hasClass('vjs-waiting'), | ||
'the plugin does not have a spinner class because timeout is disabled' | ||
); | ||
// document is visible | ||
document.visibilityState = 'visible'; | ||
this.clock.tick(45 * 1000); | ||
assert.strictEqual(errors, 0, 'did not emit an error in background after 45 seconds'); | ||
this.clock.tick(45 * 1000); | ||
assert.strictEqual(errors, 0, 'still did not emit an error in background after another 45 seconds'); | ||
}); | ||
QUnit.test('background/foreground timeout toggling is disabled after error has occurred', function(assert) { | ||
@@ -387,0 +452,0 @@ let errors = 0; |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
282540
7326
1