Socket
Socket
Sign inDemoInstall

videojs-errors

Package Overview
Dependencies
Maintainers
9
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

videojs-errors - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

7

CHANGELOG.md

@@ -0,1 +1,8 @@

<a name="3.0.2"></a>
## [3.0.2](https://github.com/brightcove/videojs-errors/compare/v3.0.1...v3.0.2) (2017-06-08)
### Bug Fixes
* show spinner if player has stalled ([#104](https://github.com/brightcove/videojs-errors/issues/104)) ([a89513f](https://github.com/brightcove/videojs-errors/commit/a89513f))
<a name="3.0.1"></a>

@@ -2,0 +9,0 @@ ## [3.0.1](https://github.com/brightcove/videojs-errors/compare/v3.0.0...v3.0.1) (2017-05-22)

29

dist/videojs-errors.cjs.js

@@ -6,3 +6,2 @@ 'use strict';

var videojs = _interopDefault(require('video.js'));
var window = _interopDefault(require('global/window'));
var document = _interopDefault(require('global/document'));

@@ -71,2 +70,4 @@

var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];

@@ -92,4 +93,11 @@

var resetMonitor = function resetMonitor() {
window.clearTimeout(monitor);
monitor = window.setTimeout(function () {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
// player already has an error

@@ -101,2 +109,14 @@ // or is not playing under normal conditions

isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
player.clearTimeout(monitor);
monitor = player.setTimeout(function () {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
player.error({

@@ -123,3 +143,4 @@ code: -2,

}
window.clearTimeout(monitor);
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};

@@ -126,0 +147,0 @@

import videojs from 'video.js';
import window from 'global/window';
import document from 'global/document';

@@ -66,2 +65,4 @@

var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];

@@ -87,4 +88,11 @@

var resetMonitor = function resetMonitor() {
window.clearTimeout(monitor);
monitor = window.setTimeout(function () {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
// player already has an error

@@ -96,2 +104,14 @@ // or is not playing under normal conditions

isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
player.clearTimeout(monitor);
monitor = player.setTimeout(function () {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
player.error({

@@ -118,3 +138,4 @@ code: -2,

}
window.clearTimeout(monitor);
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};

@@ -121,0 +142,0 @@

44

dist/videojs-errors.js
/**
* videojs-errors
* @version 3.0.1
* @version 3.0.2
* @copyright 2017 Brightcove, Inc.

@@ -17,16 +17,2 @@ * @license Apache-2.0

var win;
if (typeof window !== "undefined") {
win = window;
} else if (typeof commonjsGlobal !== "undefined") {
win = commonjsGlobal;
} else if (typeof self !== "undefined"){
win = self;
} else {
win = {};
}
var window_1 = win;
var empty = {};

@@ -120,2 +106,4 @@

var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];

@@ -141,4 +129,11 @@

var resetMonitor = function resetMonitor() {
window_1.clearTimeout(monitor);
monitor = window_1.setTimeout(function () {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
// player already has an error

@@ -150,2 +145,14 @@ // or is not playing under normal conditions

isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
player.clearTimeout(monitor);
monitor = player.setTimeout(function () {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
player.error({

@@ -172,3 +179,4 @@ code: -2,

}
window_1.clearTimeout(monitor);
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};

@@ -175,0 +183,0 @@

/**
* videojs-errors
* @version 3.0.1
* @version 3.0.2
* @copyright 2017 Brightcove, Inc.
* @license Apache-2.0
*/
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],r):e.videojsErrors=r(e.videojs)}(this,function(e){"use strict";e="default"in e?e["default"]:e;var r,o,n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i=r="undefined"!=typeof window?window:void 0!==n?n:"undefined"!=typeof self?self:{},t={},s=(Object.freeze||Object)({"default":t}),d=s&&t||s,a=void 0!==n?n:"undefined"!=typeof window?window:{};"undefined"!=typeof document?o=document:(o=a["__GLOBAL_DOCUMENT_CACHE@4"])||(o=a["__GLOBAL_DOCUMENT_CACHE@4"]=d);var l=o,c=e.getComponent("Flash"),u=!e.browser.IS_IPHONE,f=e.registerPlugin||e.plugin,p={header:"",code:"",message:"",timeout:45e3,dismiss:u,progressDisabled:!1,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"}}},h=function E(r,o){var n=void 0,t=[],s=function(r){o.errors=e.mergeOptions(o.errors,r),Object.keys(o.errors).forEach(function(e){var r=o.errors[e];r.type||(r.type=e)})};s();var d=function(){i.clearTimeout(n),n=i.setTimeout(function(){r.error()||r.paused()||r.ended()||r.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})},o.timeout),r.error()&&-2===r.error().code&&r.error(null)},a=function(){for(var e=void 0;t.length;)e=t.shift(),r.off(e[0],e[1]);i.clearTimeout(n)},u=function(e,o){var n=function(){if(!r.error()){var e=r.$(".vjs-tech");if(e&&"application/x-shockwave-flash"===e.type&&!e.vjs_getProperty)return void r.error({code:-2,type:"PLAYER_ERR_TIMEOUT"});if(r.paused())return d();if(r.ended())return d()}o.call(this)};r.on(e,n),t.push([e,n])},f=function(){var e=0;a(),d(),u(["timeupdate","adtimeupdate"],function(){var o=r.currentTime();o!==e&&(e=o,d())}),o.progressDisabled||u("progress",d)},h=function(){r.currentSrc()||r.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},v=function(){var n="",i=r.error(),t=l.createElement("div"),s="";if(i){(i=e.mergeOptions(i,o.errors[i.code||0])).message&&(n='<div class="vjs-errors-details">'+r.localize("Technical details")+'\n : <div class="vjs-errors-message">'+r.localize(i.message)+"</div>\n </div>"),4===i.code&&c&&!c.isSupported()&&(n+='<span class="vjs-errors-flashmessage">'+r.localize("If you are using an older browser please try upgrading or installing Flash.")+"</span>");var d=r.getChild("errorDisplay");if(t.className="vjs-errors-dialog",t.id="vjs-errors-dialog",s='<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">'+this.localize(i.headline)+"</h2>\n <div><b>"+this.localize("Error Code")+"</b>: "+(i.type||i.code)+"</div>\n "+n+"\n </div>",d.closeable(!("dismiss"in i)||i.dismiss)){s+='<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">'+this.localize("OK")+"</button>\n </div>",t.innerHTML=s,d.fillWith(t),d.contentEl().firstChild.appendChild(d.getChild("closeButton").el());var a=d.el().querySelector(".vjs-errors-ok-button");r.on(a,"click",function(){d.close()})}else t.innerHTML=s,d.fillWith(t);(r.currentWidth()<=600||r.currentHeight()<=250)&&d.addClass("vjs-xs"),d.one("modalclose",function(){return r.error(null)})}},y=function _(){a(),r.removeClass("vjs-errors"),r.off("play",f),r.off("play",h),r.off("dispose",_),r.off("error",v)},R=function(o){y(),E(r,e.mergeOptions(p,o))};R.extend=function(e){return s(e)},R.getAll=function(){return e.mergeOptions(o.errors)},R.disableProgress=function(e){o.progressDisabled=e,f()},r.on("play",f),r.on("play",h),r.on("dispose",y),r.on("error",v),r.ready(function(){r.addClass("vjs-errors")}),r.errors=R},v=function(r){h(this,e.mergeOptions(p,r))};return["extend","getAll","disableProgress"].forEach(function(r){v[r]=function(){e.log.warn("The errors."+r+"() method is not available until the plugin has been initialized!")}}),f("errors",v),v});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],r):e.videojsErrors=r(e.videojs)}(this,function(e){"use strict";e="default"in e?e["default"]:e;var r,o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n={},i=(Object.freeze||Object)({"default":n}),t=i&&n||i,s=void 0!==o?o:"undefined"!=typeof window?window:{};"undefined"!=typeof document?r=document:(r=s["__GLOBAL_DOCUMENT_CACHE@4"])||(r=s["__GLOBAL_DOCUMENT_CACHE@4"]=t);var d=r,a=e.getComponent("Flash"),l=!e.browser.IS_IPHONE,c=e.registerPlugin||e.plugin,u={header:"",code:"",message:"",timeout:45e3,dismiss:l,progressDisabled:!1,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"}}},f=function v(r,o){var n=void 0,i=void 0,t=void 0,s=[],l=function(r){o.errors=e.mergeOptions(o.errors,r),Object.keys(o.errors).forEach(function(e){var r=o.errors[e];r.type||(r.type=e)})};l();var c=function(){r.clearTimeout(i),t&&(t=!1,r.removeClass("vjs-waiting")),i=r.setTimeout(function(){r.error()||r.paused()||r.ended()||(t=!0,r.addClass("vjs-waiting"))},1e3),r.clearTimeout(n),n=r.setTimeout(function(){r.error()||r.paused()||r.ended()||r.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})},o.timeout),r.error()&&-2===r.error().code&&r.error(null)},f=function(){for(var e=void 0;s.length;)e=s.shift(),r.off(e[0],e[1]);r.clearTimeout(n),r.clearTimeout(i)},p=function(e,o){var n=function(){if(!r.error()){var e=r.$(".vjs-tech");if(e&&"application/x-shockwave-flash"===e.type&&!e.vjs_getProperty)return void r.error({code:-2,type:"PLAYER_ERR_TIMEOUT"});if(r.paused())return c();if(r.ended())return c()}o.call(this)};r.on(e,n),s.push([e,n])},h=function(){var e=0;f(),c(),p(["timeupdate","adtimeupdate"],function(){var o=r.currentTime();o!==e&&(e=o,c())}),o.progressDisabled||p("progress",c)},E=function(){r.currentSrc()||r.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},R=function(){var n="",i=r.error(),t=d.createElement("div"),s="";if(i){(i=e.mergeOptions(i,o.errors[i.code||0])).message&&(n='<div class="vjs-errors-details">'+r.localize("Technical details")+'\n : <div class="vjs-errors-message">'+r.localize(i.message)+"</div>\n </div>"),4===i.code&&a&&!a.isSupported()&&(n+='<span class="vjs-errors-flashmessage">'+r.localize("If you are using an older browser please try upgrading or installing Flash.")+"</span>");var l=r.getChild("errorDisplay");if(t.className="vjs-errors-dialog",t.id="vjs-errors-dialog",s='<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">'+this.localize(i.headline)+"</h2>\n <div><b>"+this.localize("Error Code")+"</b>: "+(i.type||i.code)+"</div>\n "+n+"\n </div>",l.closeable(!("dismiss"in i)||i.dismiss)){s+='<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">'+this.localize("OK")+"</button>\n </div>",t.innerHTML=s,l.fillWith(t),l.contentEl().firstChild.appendChild(l.getChild("closeButton").el());var c=l.el().querySelector(".vjs-errors-ok-button");r.on(c,"click",function(){l.close()})}else t.innerHTML=s,l.fillWith(t);(r.currentWidth()<=600||r.currentHeight()<=250)&&l.addClass("vjs-xs"),l.one("modalclose",function(){return r.error(null)})}},y=function _(){f(),r.removeClass("vjs-errors"),r.off("play",h),r.off("play",E),r.off("dispose",_),r.off("error",R)},g=function(o){y(),v(r,e.mergeOptions(u,o))};g.extend=function(e){return l(e)},g.getAll=function(){return e.mergeOptions(o.errors)},g.disableProgress=function(e){o.progressDisabled=e,h()},r.on("play",h),r.on("play",E),r.on("dispose",y),r.on("error",R),r.ready(function(){r.addClass("vjs-errors")}),r.errors=g},p=function(r){f(this,e.mergeOptions(u,r))};return["extend","getAll","disableProgress"].forEach(function(r){p[r]=function(){e.log.warn("The errors."+r+"() method is not available until the plugin has been initialized!")}}),c("errors",p),p});
{
"name": "videojs-errors",
"version": "3.0.1",
"version": "3.0.2",
"author": "Brightcove, Inc.",

@@ -5,0 +5,0 @@ "description": "A Video.js plugin for custom error reporting",

import videojs from 'video.js';
import window from 'global/window';
import document from 'global/document';

@@ -68,2 +67,4 @@

let monitor;
let waiting;
let isStalling;
const listeners = [];

@@ -89,4 +90,11 @@

const resetMonitor = function() {
window.clearTimeout(monitor);
monitor = window.setTimeout(function() {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
// start the loading spinner if player has stalled
waiting = player.setTimeout(function() {
// player already has an error

@@ -98,2 +106,14 @@ // or is not playing under normal conditions

isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
player.clearTimeout(monitor);
monitor = player.setTimeout(function() {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
player.error({

@@ -120,3 +140,4 @@ code: -2,

}
window.clearTimeout(monitor);
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};

@@ -123,0 +144,0 @@

@@ -37,16 +37,2 @@ (function (QUnit,sinon,videojs) {

var win;
if (typeof window !== "undefined") {
win = window;
} else if (typeof commonjsGlobal !== "undefined") {
win = commonjsGlobal;
} else if (typeof self !== "undefined"){
win = self;
} else {
win = {};
}
var window_1 = win;
var FlashObj = videojs.getComponent('Flash');

@@ -113,2 +99,4 @@ var defaultDismiss = !videojs.browser.IS_IPHONE;

var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];

@@ -134,4 +122,11 @@

var resetMonitor = function resetMonitor() {
window_1.clearTimeout(monitor);
monitor = window_1.setTimeout(function () {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
// player already has an error

@@ -143,2 +138,14 @@ // or is not playing under normal conditions

isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
player.clearTimeout(monitor);
monitor = player.setTimeout(function () {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
player.error({

@@ -165,3 +172,4 @@ code: -2,

}
window_1.clearTimeout(monitor);
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};

@@ -428,2 +436,25 @@

QUnit.test('no progress for 1 second shows the loading spinner', function (assert) {
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');
});
QUnit.test('progress events while playing reset the spinner', function (assert) {
this.player.src(sources);
this.player.trigger('play');
// stalled for awhile
this.clock.tick(44 * 1000);
assert.ok(this.player.hasClass('vjs-waiting'), 'the plugin adds spinner class to the player');
// resume playback
this.player.currentTime = function () {
return 1;
};
this.player.trigger('timeupdate');
assert.notOk(this.player.hasClass('vjs-waiting'), 'spinner removed');
});
QUnit.test('no progress for 45 seconds is an error', function (assert) {

@@ -430,0 +461,0 @@ var errors$$1 = 0;

@@ -97,2 +97,31 @@ import document from 'global/document';

QUnit.test('no progress for 1 second shows the loading spinner', function(assert) {
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'
);
});
QUnit.test('progress events while playing reset the spinner', function(assert) {
this.player.src(sources);
this.player.trigger('play');
// stalled for awhile
this.clock.tick(44 * 1000);
assert.ok(
this.player.hasClass('vjs-waiting'),
'the plugin adds spinner class to the player'
);
// resume playback
this.player.currentTime = function() {
return 1;
};
this.player.trigger('timeupdate');
assert.notOk(this.player.hasClass('vjs-waiting'), 'spinner removed');
});
QUnit.test('no progress for 45 seconds is an error', function(assert) {

@@ -99,0 +128,0 @@ let errors = 0;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc