Socket
Socket
Sign inDemoInstall

videojs-errors

Package Overview
Dependencies
Maintainers
10
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.1.0 to 4.0.0

23

CHANGELOG.md

@@ -0,1 +1,24 @@

<a name="4.0.0"></a>
# [4.0.0](https://github.com/brightcove/videojs-errors/compare/v3.1.0...v4.0.0) (2018-05-02)
### Features
* Add timeout getter/setter ([#114](https://github.com/brightcove/videojs-errors/issues/114)) ([cb45723](https://github.com/brightcove/videojs-errors/commit/cb45723))
* drop v5 support ([#119](https://github.com/brightcove/videojs-errors/issues/119)) ([f4440c1](https://github.com/brightcove/videojs-errors/commit/f4440c1))
### Bug Fixes
* make the plugin ready for videojs 7 ([#117](https://github.com/brightcove/videojs-errors/issues/117)) ([8d96f2a](https://github.com/brightcove/videojs-errors/commit/8d96f2a)), closes [#116](https://github.com/brightcove/videojs-errors/issues/116)
* Restart timeout monitor if playing when reinitialised ([#113](https://github.com/brightcove/videojs-errors/issues/113)) ([af868ed](https://github.com/brightcove/videojs-errors/commit/af868ed))
### Documentation
* **README:** Add usage npm/bundler usage ([#108](https://github.com/brightcove/videojs-errors/issues/108)) ([ec86764](https://github.com/brightcove/videojs-errors/commit/ec86764))
* **README:** fix typo ([ec724b7](https://github.com/brightcove/videojs-errors/commit/ec724b7))
### BREAKING CHANGES
* drop v5 support.
<a name="3.1.0"></a>

@@ -2,0 +25,0 @@ # [3.1.0](https://github.com/brightcove/videojs-errors/compare/v1.0.0...v3.1.0) (2017-12-13)

@@ -292,2 +292,15 @@ 'use strict';

// Get / set timeout value. Restart monitor if changed.
reInitPlugin.timeout = function (timeout) {
if (typeof timeout === 'undefined') {
return options.timeout;
}
if (timeout !== options.timeout) {
options.timeout = timeout;
if (!player.paused()) {
onPlayStartMonitor();
}
}
};
reInitPlugin.disableProgress = function (disabled) {

@@ -307,2 +320,7 @@ options.progressDisabled = disabled;

// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
player.errors = reInitPlugin;

@@ -309,0 +327,0 @@ };

@@ -288,2 +288,15 @@ import videojs from 'video.js';

// Get / set timeout value. Restart monitor if changed.
reInitPlugin.timeout = function (timeout) {
if (typeof timeout === 'undefined') {
return options.timeout;
}
if (timeout !== options.timeout) {
options.timeout = timeout;
if (!player.paused()) {
onPlayStartMonitor();
}
}
};
reInitPlugin.disableProgress = function (disabled) {

@@ -303,2 +316,7 @@ options.progressDisabled = disabled;

// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
player.errors = reInitPlugin;

@@ -305,0 +323,0 @@ };

22

dist/videojs-errors.js
/**
* videojs-errors
* @version 3.1.0
* @copyright 2017 Brightcove, Inc.
* @version 4.0.0
* @copyright 2018 Brightcove, Inc.
* @license Apache-2.0

@@ -328,2 +328,15 @@ */

// Get / set timeout value. Restart monitor if changed.
reInitPlugin.timeout = function (timeout) {
if (typeof timeout === 'undefined') {
return options.timeout;
}
if (timeout !== options.timeout) {
options.timeout = timeout;
if (!player.paused()) {
onPlayStartMonitor();
}
}
};
reInitPlugin.disableProgress = function (disabled) {

@@ -343,2 +356,7 @@ options.progressDisabled = disabled;

// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
player.errors = reInitPlugin;

@@ -345,0 +363,0 @@ };

6

dist/videojs-errors.min.js
/**
* videojs-errors
* @version 3.1.0
* @copyright 2017 Brightcove, Inc.
* @version 4.0.0
* @copyright 2018 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=e&&e.hasOwnProperty("default")?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"},FLASHLS_ERR_CROSS_DOMAIN:{headline:"The video could not be loaded: crossdomain access denied."}}},f=function(r){!function o(r,n){var i=void 0,t=void 0,s=void 0,l=[],c=function(r){n.errors=e.mergeOptions(n.errors,r),Object.keys(n.errors).forEach(function(e){var r=n.errors[e];r.type||(r.type=e)})};c();var f=function(){r.clearTimeout(t),s&&(s=!1,r.removeClass("vjs-waiting")),t=r.setTimeout(function(){r.error()||r.paused()||r.ended()||(s=!0,r.addClass("vjs-waiting"))},1e3),r.clearTimeout(i),i=r.setTimeout(function(){r.error()||r.paused()||r.ended()||r.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})},n.timeout),r.error()&&-2===r.error().code&&r.error(null)},p=function(){for(var e=void 0;l.length;)e=l.shift(),r.off(e[0],e[1]);r.clearTimeout(i),r.clearTimeout(t)},h=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 f();if(r.ended())return f()}o.call(this)};r.on(e,n),l.push([e,n])},v=function(){var e=0;p(),f(),h(["timeupdate","adtimeupdate"],function(){var o=r.currentTime();o!==e&&(e=o,f())}),n.progressDisabled||h("progress",f)},E=function(){r.currentSrc()||r.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},R=function(){var o="",i=r.error(),t=d.createElement("div"),s="";if(i){(i=e.mergeOptions(i,n.errors[i.code||i.type||0])).message&&(o='<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()&&(o+='<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 "+o+"\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 g(){p(),r.removeClass("vjs-errors"),r.off("play",v),r.off("play",E),r.off("dispose",g),r.off(["aderror","error"],R)},_=function(n){y(),o(r,e.mergeOptions(u,n))};_.extend=function(e){return c(e)},_.getAll=function(){return e.mergeOptions(n.errors)},_.disableProgress=function(e){n.progressDisabled=e,v()},r.on("play",v),r.on("play",E),r.on("dispose",y),r.on(["aderror","error"],R),r.ready(function(){r.addClass("vjs-errors")}),r.errors=_}(this,e.mergeOptions(u,r))};return["extend","getAll","disableProgress"].forEach(function(r){f[r]=function(){e.log.warn("The errors."+r+"() method is not available until the plugin has been initialized!")}}),c("errors",f),f});
!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=e&&e.hasOwnProperty("default")?e["default"]:e;var r,o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},n=(Object.freeze||Object)({"default":i}),t=n&&i||n,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"},FLASHLS_ERR_CROSS_DOMAIN:{headline:"The video could not be loaded: crossdomain access denied."}}},f=function(r){!function o(r,i){var n=void 0,t=void 0,s=void 0,l=[],c=function(r){i.errors=e.mergeOptions(i.errors,r),Object.keys(i.errors).forEach(function(e){var r=i.errors[e];r.type||(r.type=e)})};c();var f=function(){r.clearTimeout(t),s&&(s=!1,r.removeClass("vjs-waiting")),t=r.setTimeout(function(){r.error()||r.paused()||r.ended()||(s=!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"})},i.timeout),r.error()&&-2===r.error().code&&r.error(null)},p=function(){for(var e=void 0;l.length;)e=l.shift(),r.off(e[0],e[1]);r.clearTimeout(n),r.clearTimeout(t)},v=function(e,o){var i=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 f();if(r.ended())return f()}o.call(this)};r.on(e,i),l.push([e,i])},h=function(){var e=0;p(),f(),v(["timeupdate","adtimeupdate"],function(){var o=r.currentTime();o!==e&&(e=o,f())}),i.progressDisabled||v("progress",f)},E=function(){r.currentSrc()||r.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},R=function(){var o="",n=r.error(),t=d.createElement("div"),s="";if(n){(n=e.mergeOptions(n,i.errors[n.code||n.type||0])).message&&(o='<div class="vjs-errors-details">'+r.localize("Technical details")+'\n : <div class="vjs-errors-message">'+r.localize(n.message)+"</div>\n </div>"),4===n.code&&a&&!a.isSupported()&&(o+='<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(n.headline)+"</h2>\n <div><b>"+this.localize("Error Code")+"</b>: "+(n.type||n.code)+"</div>\n "+o+"\n </div>",l.closeable(!("dismiss"in n)||n.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 m(){p(),r.removeClass("vjs-errors"),r.off("play",h),r.off("play",E),r.off("dispose",m),r.off(["aderror","error"],R)},_=function(i){y(),o(r,e.mergeOptions(u,i))};_.extend=function(e){return c(e)},_.getAll=function(){return e.mergeOptions(i.errors)},_.timeout=function(e){if(void 0===e)return i.timeout;e!==i.timeout&&(i.timeout=e,r.paused()||h())},_.disableProgress=function(e){i.progressDisabled=e,h()},r.on("play",h),r.on("play",E),r.on("dispose",y),r.on(["aderror","error"],R),r.ready(function(){r.addClass("vjs-errors")}),r.paused()||h(),r.errors=_}(this,e.mergeOptions(u,r))};return["extend","getAll","disableProgress"].forEach(function(r){f[r]=function(){e.log.warn("The errors."+r+"() method is not available until the plugin has been initialized!")}}),c("errors",f),f});
{
"name": "videojs-errors",
"version": "3.1.0",
"version": "4.0.0",
"author": "Brightcove, Inc.",

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

"global": "^4.3.2",
"video.js": "^5.19.2"
"video.js": "^6.8.0 || ^7.0.0"
},

@@ -104,2 +104,3 @@ "devDependencies": {

"karma-safari-launcher": "^1.0.0",
"karma-safaritechpreview-launcher": "0.0.6",
"mkdirp": "^0.5.1",

@@ -106,0 +107,0 @@ "node-sass": "^4.5.3",

@@ -19,2 +19,3 @@ # videojs-errors

- [`getAll()`](#getall)
- [`timeout()`](#timeout)
- [Known Issues](#known-issues)

@@ -25,3 +26,19 @@

## Getting Started
**Importing via npm/Babel/Browserify/webpack**
```shell
npm install videojs-errors
```
Then import in your JavaScript
```js
import videojs from 'video.js';
import 'videojs-errors';
```
Installing the styles will depend on your build tool.
[Here's](http://brunch.io/docs/using-modules) an example of including styles with brunch. See Including Module's styles section.
**Importing via script tag**
The plugin automatically registers itself when you include videojs.errors.js in your page:

@@ -150,4 +167,12 @@

### `timeout()`
After the errors plugin has been initialized on a player, a `timeout()` method is available on the `errors()` plugin method.
A new timeout may be set by passing a timeout in milliseconds, e.g. `player.errors.timeout(5 * 1000)`.
If no argument is passed, the current timeout value is returned.
## Known Issues
On iPhones, default errors are not dismissible. The video element intercepts all user interaction so error message dialogs miss the tap events. If your video is busted anyways, you may not be that upset about this.

@@ -298,2 +298,15 @@ import videojs from 'video.js';

// Get / set timeout value. Restart monitor if changed.
reInitPlugin.timeout = function(timeout) {
if (typeof timeout === 'undefined') {
return options.timeout;
}
if (timeout !== options.timeout) {
options.timeout = timeout;
if (!player.paused()) {
onPlayStartMonitor();
}
}
};
reInitPlugin.disableProgress = function(disabled) {

@@ -313,2 +326,7 @@ options.progressDisabled = disabled;

// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
player.errors = reInitPlugin;

@@ -323,3 +341,5 @@ };

errors[k] = function() {
videojs.log.warn(`The errors.${k}() method is not available until the plugin has been initialized!`);
videojs.log.warn(
`The errors.${k}() method is not available until the plugin has been initialized!`
);
};

@@ -326,0 +346,0 @@ });

@@ -321,2 +321,15 @@ (function (QUnit,sinon,videojs) {

// Get / set timeout value. Restart monitor if changed.
reInitPlugin.timeout = function (timeout) {
if (typeof timeout === 'undefined') {
return options.timeout;
}
if (timeout !== options.timeout) {
options.timeout = timeout;
if (!player.paused()) {
onPlayStartMonitor();
}
}
};
reInitPlugin.disableProgress = function (disabled) {

@@ -336,2 +349,7 @@ options.progressDisabled = disabled;

// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
player.errors = reInitPlugin;

@@ -543,6 +561,10 @@ };

this.player.trigger('play');
this.player.trigger('dispose');
this.player.dispose();
this.clock.tick(45 * 1000);
assert.ok(!this.player.error(), 'should not throw player error when dispose is called.');
// reset this.player because otherwise afterEach will fail
this.fixture.appendChild(this.video);
this.player = videojs(this.video);
});

@@ -569,2 +591,48 @@

QUnit.test('reinitialising plugin during playback starts timeout handler', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// reinitialise while playing
this.player.errors();
this.clock.tick(45 * 1000);
assert.strictEqual(errors$$1, 1, 'emitted an error');
assert.strictEqual(this.player.error().code, -2, 'error code is -2');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_TIMEOUT');
});
QUnit.test('timeout can be got and set', function (assert) {
assert.strictEqual(this.player.errors.timeout(), 45 * 1000, 'default timeout reported');
this.player.errors.timeout(1 * 1000);
assert.strictEqual(this.player.errors.timeout(), 1 * 1000, 'timeout was updated');
});
QUnit.test('updating timeout during playback restarts timeout monitor', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// reinitialise while playing
this.player.errors.timeout(1000);
this.clock.tick(1 * 1000);
assert.strictEqual(errors$$1, 1, 'emitted an error');
assert.strictEqual(this.player.error().code, -2, 'error code is -2');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_TIMEOUT');
});
// safari 7 on OSX can emit stalls when playback is just fine

@@ -571,0 +639,0 @@ QUnit.test('stalling by itself is not an error', function (assert) {

@@ -209,3 +209,3 @@ import document from 'global/document';

this.player.trigger('play');
this.player.trigger('dispose');
this.player.dispose();
this.clock.tick(45 * 1000);

@@ -215,2 +215,6 @@

'should not throw player error when dispose is called.');
// reset this.player because otherwise afterEach will fail
this.fixture.appendChild(this.video);
this.player = videojs(this.video);
});

@@ -237,2 +241,48 @@

QUnit.test('reinitialising plugin during playback starts timeout handler', function(assert) {
let errors = 0;
this.player.on('error', function() {
errors++;
});
this.player.src(sources);
this.player.trigger('play');
// reinitialise while playing
this.player.errors();
this.clock.tick(45 * 1000);
assert.strictEqual(errors, 1, 'emitted an error');
assert.strictEqual(this.player.error().code, -2, 'error code is -2');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_TIMEOUT');
});
QUnit.test('timeout can be got and set', function(assert) {
assert.strictEqual(this.player.errors.timeout(), 45 * 1000, 'default timeout reported');
this.player.errors.timeout(1 * 1000);
assert.strictEqual(this.player.errors.timeout(), 1 * 1000, 'timeout was updated');
});
QUnit.test('updating timeout during playback restarts timeout monitor', function(assert) {
let errors = 0;
this.player.on('error', function() {
errors++;
});
this.player.src(sources);
this.player.trigger('play');
// reinitialise while playing
this.player.errors.timeout(1000);
this.clock.tick(1 * 1000);
assert.strictEqual(errors, 1, 'emitted an error');
assert.strictEqual(this.player.error().code, -2, 'error code is -2');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_TIMEOUT');
});
// safari 7 on OSX can emit stalls when playback is just fine

@@ -239,0 +289,0 @@ QUnit.test('stalling by itself is not an error', function(assert) {

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