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 4.1.0 to 4.1.1

scripts/jsdoc.json

7

CHANGELOG.md

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

<a name="4.1.1"></a>
## [4.1.1](https://github.com/brightcove/videojs-errors/compare/v4.1.0...v4.1.1) (2018-07-05)
### Chores
* generator v6 ([#122](https://github.com/brightcove/videojs-errors/issues/122)) ([846d151](https://github.com/brightcove/videojs-errors/commit/846d151))
<a name="4.1.0"></a>

@@ -2,0 +9,0 @@ # [4.1.0](https://github.com/brightcove/videojs-errors/compare/v4.0.0...v4.1.0) (2018-05-08)

34

dist/videojs-errors.cjs.js

@@ -0,1 +1,2 @@

/*! @name videojs-errors @version 4.1.1 @license Apache-2.0 */
'use strict';

@@ -6,6 +7,33 @@

var videojs = _interopDefault(require('video.js'));
var document = _interopDefault(require('global/document'));
var version = "4.1.0";
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var empty = {};
var empty$1 = /*#__PURE__*/Object.freeze({
default: empty
});
var minDoc = ( empty$1 && empty ) || empty$1;
var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
typeof window !== 'undefined' ? window : {};
var doccy;
if (typeof document !== 'undefined') {
doccy = document;
} else {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
if (!doccy) {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
}
}
var document_1 = doccy;
var version = "4.1.1";
var FlashObj = videojs.getComponent('Flash');

@@ -217,3 +245,3 @@ var defaultDismiss = !videojs.browser.IS_IPHONE;

var error = player.error();
var content = document.createElement('div');
var content = document_1.createElement('div');
var dialogContent = '';

@@ -220,0 +248,0 @@

164

dist/videojs-errors.es.js

@@ -0,14 +1,42 @@

/*! @name videojs-errors @version 4.1.1 @license Apache-2.0 */
import videojs from 'video.js';
import document from 'global/document';
var version = "4.1.0";
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var FlashObj = videojs.getComponent('Flash');
var defaultDismiss = !videojs.browser.IS_IPHONE;
var empty = {};
var empty$1 = /*#__PURE__*/Object.freeze({
default: empty
});
var minDoc = ( empty$1 && empty ) || empty$1;
var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
typeof window !== 'undefined' ? window : {};
var doccy;
if (typeof document !== 'undefined') {
doccy = document;
} else {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
if (!doccy) {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
}
}
var document_1 = doccy;
var version = "4.1.1";
const FlashObj = videojs.getComponent('Flash');
const defaultDismiss = !videojs.browser.IS_IPHONE;
// Video.js 5/6 cross-compatibility.
var registerPlugin = videojs.registerPlugin || videojs.plugin;
const registerPlugin = videojs.registerPlugin || videojs.plugin;
// Default options for the plugin.
var defaults = {
const defaults = {
header: '',

@@ -27,3 +55,4 @@ code: '',

type: 'MEDIA_ERR_NETWORK',
headline: 'The video connection was lost, please confirm you are ' + 'connected to the internet'
headline: 'The video connection was lost, please confirm you are ' +
'connected to the internet'
},

@@ -40,3 +69,4 @@ '3': {

type: 'MEDIA_ERR_ENCRYPTED',
headline: 'The video you are trying to watch is encrypted and we do not know how ' + 'to decrypt it'
headline: 'The video you are trying to watch is encrypted and we do not know how ' +
'to decrypt it'
},

@@ -70,14 +100,14 @@ 'unknown': {

var initPlugin = function initPlugin(player, options) {
var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];
const initPlugin = function(player, options) {
let monitor;
let waiting;
let isStalling;
const listeners = [];
var updateErrors = function updateErrors(updates) {
const updateErrors = function(updates) {
options.errors = videojs.mergeOptions(options.errors, updates);
// Create `code`s from errors which don't have them (based on their keys).
Object.keys(options.errors).forEach(function (k) {
var err = options.errors[k];
Object.keys(options.errors).forEach(k => {
const err = options.errors[k];

@@ -94,3 +124,3 @@ if (!err.type) {

// clears the previous monitor timeout and sets up a new one
var resetMonitor = function resetMonitor() {
const resetMonitor = function() {
// at this point the player has recovered

@@ -104,3 +134,3 @@ player.clearTimeout(waiting);

// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
waiting = player.setTimeout(function() {
// player already has an error

@@ -117,3 +147,3 @@ // or is not playing under normal conditions

player.clearTimeout(monitor);
monitor = player.setTimeout(function () {
monitor = player.setTimeout(function() {
// player already has an error

@@ -139,4 +169,4 @@ // or is not playing under normal conditions

// clear any previously registered listeners
var cleanup = function cleanup() {
var listener = void 0;
const cleanup = function() {
let listener;

@@ -152,4 +182,4 @@ while (listeners.length) {

// creates and tracks a player listener if the player looks alive
var healthcheck = function healthcheck(type, fn) {
var check = function check() {
const healthcheck = function(type, fn) {
const check = function() {
// if there's an error do not reset the monitor and

@@ -159,5 +189,7 @@ // clear the error unless time is progressing

// error if using Flash and its API is unavailable
var tech = player.$('.vjs-tech');
const tech = player.$('.vjs-tech');
if (tech && tech.type === 'application/x-shockwave-flash' && !tech.vjs_getProperty) {
if (tech &&
tech.type === 'application/x-shockwave-flash' &&
!tech.vjs_getProperty) {
player.error({

@@ -187,4 +219,4 @@ code: -2,

var onPlayStartMonitor = function onPlayStartMonitor() {
var lastTime = 0;
const onPlayStartMonitor = function() {
let lastTime = 0;

@@ -195,4 +227,4 @@ cleanup();

resetMonitor();
healthcheck(['timeupdate', 'adtimeupdate'], function () {
var currentTime = player.currentTime();
healthcheck(['timeupdate', 'adtimeupdate'], function() {
const currentTime = player.currentTime();

@@ -211,3 +243,3 @@ // playback is operating normally or has recovered

var onPlayNoSource = function onPlayNoSource() {
const onPlayNoSource = function() {
if (!player.currentSrc()) {

@@ -221,7 +253,7 @@ player.error({

var onErrorHandler = function onErrorHandler() {
var details = '';
var error = player.error();
var content = document.createElement('div');
var dialogContent = '';
const onErrorHandler = function() {
let details = '';
let error = player.error();
const content = document_1.createElement('div');
let dialogContent = '';

@@ -237,22 +269,34 @@ // In the rare case when `error()` does not return an error object,

if (error.message) {
details = '<div class="vjs-errors-details">' + player.localize('Technical details') + '\n : <div class="vjs-errors-message">' + player.localize(error.message) + '</div>\n </div>';
details = `<div class="vjs-errors-details">${player.localize('Technical details')}
: <div class="vjs-errors-message">${player.localize(error.message)}</div>
</div>`;
}
if (error.code === 4 && FlashObj && !FlashObj.isSupported()) {
var flashMessage = player.localize('If you are using an older browser please try upgrading or installing Flash.');
const flashMessage = player.localize(
'If you are using an older browser please try upgrading or installing Flash.'
);
details += '<span class="vjs-errors-flashmessage">' + flashMessage + '</span>';
details += `<span class="vjs-errors-flashmessage">${flashMessage}</span>`;
}
var display = player.getChild('errorDisplay');
const display = player.getChild('errorDisplay');
content.className = 'vjs-errors-dialog';
content.id = 'vjs-errors-dialog';
dialogContent = '<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">' + this.localize(error.headline) + '</h2>\n <div><b>' + this.localize('Error Code') + '</b>: ' + (error.type || error.code) + '</div>\n ' + details + '\n </div>';
dialogContent =
`<div class="vjs-errors-content-container">
<h2 class="vjs-errors-headline">${this.localize(error.headline)}</h2>
<div><b>${this.localize('Error Code')}</b>: ${(error.type || error.code)}</div>
${details}
</div>`;
var closeable = display.closeable(!('dismiss' in error) || error.dismiss);
const closeable = display.closeable(!('dismiss' in error) || error.dismiss);
// We should get a close button
if (closeable) {
dialogContent += '<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">' + this.localize('OK') + '</button>\n </div>';
dialogContent +=
`<div class="vjs-errors-ok-button-container">
<button class="vjs-errors-ok-button">${this.localize('OK')}</button>
</div>`;
content.innerHTML = dialogContent;

@@ -263,5 +307,5 @@ display.fillWith(content);

var okButton = display.el().querySelector('.vjs-errors-ok-button');
const okButton = display.el().querySelector('.vjs-errors-ok-button');
player.on(okButton, 'click', function () {
player.on(okButton, 'click', function() {
display.close();

@@ -278,8 +322,6 @@ });

display.one('modalclose', function () {
return player.error(null);
});
display.one('modalclose', () => player.error(null));
};
var onDisposeHandler = function onDisposeHandler() {
const onDisposeHandler = function() {
cleanup();

@@ -294,3 +336,3 @@

var reInitPlugin = function reInitPlugin(newOptions) {
const reInitPlugin = function(newOptions) {
onDisposeHandler();

@@ -300,11 +342,7 @@ initPlugin(player, videojs.mergeOptions(defaults, newOptions));

reInitPlugin.extend = function (errors) {
return updateErrors(errors);
};
reInitPlugin.getAll = function () {
return videojs.mergeOptions(options.errors);
};
reInitPlugin.extend = (errors) => updateErrors(errors);
reInitPlugin.getAll = () => videojs.mergeOptions(options.errors);
// Get / set timeout value. Restart monitor if changed.
reInitPlugin.timeout = function (timeout) {
reInitPlugin.timeout = function(timeout) {
if (typeof timeout === 'undefined') {

@@ -321,3 +359,3 @@ return options.timeout;

reInitPlugin.disableProgress = function (disabled) {
reInitPlugin.disableProgress = function(disabled) {
options.progressDisabled = disabled;

@@ -332,3 +370,3 @@ onPlayStartMonitor();

player.ready(function () {
player.ready(() => {
player.addClass('vjs-errors');

@@ -348,9 +386,11 @@ });

var errors = function errors(options) {
const errors = function(options) {
initPlugin(this, videojs.mergeOptions(defaults, options));
};
['extend', 'getAll', 'disableProgress'].forEach(function (k) {
errors[k] = function () {
videojs.log.warn('The errors.' + k + '() method is not available until the plugin has been initialized!');
['extend', 'getAll', 'disableProgress'].forEach(k => {
errors[k] = function() {
videojs.log.warn(
`The errors.${k}() method is not available until the plugin has been initialized!`
);
};

@@ -357,0 +397,0 @@ });

@@ -1,386 +0,353 @@

/**
* videojs-errors
* @version 4.1.0
* @copyright 2018 Brightcove, Inc.
* @license Apache-2.0
*/
/*! @name videojs-errors @version 4.1.1 @license Apache-2.0 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js')) :
typeof define === 'function' && define.amd ? define(['video.js'], factory) :
(global.videojsErrors = factory(global.videojs));
}(this, (function (videojs) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('video.js'), require('global/document')) :
typeof define === 'function' && define.amd ? define(['video.js', 'global/document'], factory) :
(global.videojsErrors = factory(global.videojs,global.document));
}(this, (function (videojs,document) { 'use strict';
videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs;
videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs;
document = document && document.hasOwnProperty('default') ? document['default'] : document;
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var version = "4.1.1";
var empty = {};
var FlashObj = videojs.getComponent('Flash');
var defaultDismiss = !videojs.browser.IS_IPHONE;
// Video.js 5/6 cross-compatibility.
var registerPlugin = videojs.registerPlugin || videojs.plugin;
var empty$1 = (Object.freeze || Object)({
'default': empty
});
// Default options for the plugin.
var defaults = {
header: '',
code: '',
message: '',
timeout: 45 * 1000,
dismiss: defaultDismiss,
progressDisabled: false,
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.'
}
}
};
var minDoc = ( empty$1 && empty ) || empty$1;
var initPlugin = function initPlugin(player, options) {
var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];
var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
typeof window !== 'undefined' ? window : {};
var updateErrors = function updateErrors(updates) {
options.errors = videojs.mergeOptions(options.errors, updates);
// Create `code`s from errors which don't have them (based on their keys).
Object.keys(options.errors).forEach(function (k) {
var err = options.errors[k];
var doccy;
if (!err.type) {
err.type = k;
}
});
};
if (typeof document !== 'undefined') {
doccy = document;
} else {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
// Make sure we flesh out initially-provided errors.
updateErrors();
if (!doccy) {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
}
}
// clears the previous monitor timeout and sets up a new one
var resetMonitor = function resetMonitor() {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
var document_1 = doccy;
// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
var version = "4.1.0";
isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
var FlashObj = videojs.getComponent('Flash');
var defaultDismiss = !videojs.browser.IS_IPHONE;
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;
}
// Video.js 5/6 cross-compatibility.
var registerPlugin = videojs.registerPlugin || videojs.plugin;
player.error({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
}, options.timeout);
// Default options for the plugin.
var defaults = {
header: '',
code: '',
message: '',
timeout: 45 * 1000,
dismiss: defaultDismiss,
progressDisabled: false,
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.'
}
}
};
// clear out any existing player timeout
// playback has recovered
if (player.error() && player.error().code === -2) {
player.error(null);
}
};
var initPlugin = function initPlugin(player, options) {
var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];
// clear any previously registered listeners
var cleanup = function cleanup() {
var listener = void 0;
var updateErrors = function updateErrors(updates) {
options.errors = videojs.mergeOptions(options.errors, updates);
// Create `code`s from errors which don't have them (based on their keys).
Object.keys(options.errors).forEach(function (k) {
var err = options.errors[k];
if (!err.type) {
err.type = k;
while (listeners.length) {
listener = listeners.shift();
player.off(listener[0], listener[1]);
}
});
};
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};
// Make sure we flesh out initially-provided errors.
updateErrors();
// creates and tracks a player listener if the player looks alive
var healthcheck = function healthcheck(type, fn) {
var check = function check() {
// if there's an error do not reset the monitor and
// clear the error unless time is progressing
if (!player.error()) {
// error if using Flash and its API is unavailable
var tech = player.$('.vjs-tech');
// clears the previous monitor timeout and sets up a new one
var resetMonitor = function resetMonitor() {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
if (tech && tech.type === 'application/x-shockwave-flash' && !tech.vjs_getProperty) {
player.error({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
return;
}
// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
// playback isn't expected if the player is paused
if (player.paused()) {
return resetMonitor();
}
// playback isn't expected once the video has ended
if (player.ended()) {
return resetMonitor();
}
}
isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
fn.call(this);
};
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.on(type, check);
listeners.push([type, check]);
};
player.error({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
}, options.timeout);
var onPlayStartMonitor = function onPlayStartMonitor() {
var lastTime = 0;
// clear out any existing player timeout
// playback has recovered
if (player.error() && player.error().code === -2) {
player.error(null);
}
};
cleanup();
// clear any previously registered listeners
var cleanup = function cleanup() {
var listener = void 0;
// if no playback is detected for long enough, trigger a timeout error
resetMonitor();
healthcheck(['timeupdate', 'adtimeupdate'], function () {
var currentTime = player.currentTime();
while (listeners.length) {
listener = listeners.shift();
player.off(listener[0], listener[1]);
}
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};
// creates and tracks a player listener if the player looks alive
var healthcheck = function healthcheck(type, fn) {
var check = function check() {
// if there's an error do not reset the monitor and
// clear the error unless time is progressing
if (!player.error()) {
// error if using Flash and its API is unavailable
var tech = player.$('.vjs-tech');
if (tech && tech.type === 'application/x-shockwave-flash' && !tech.vjs_getProperty) {
player.error({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
return;
// playback is operating normally or has recovered
if (currentTime !== lastTime) {
lastTime = currentTime;
resetMonitor();
}
});
// playback isn't expected if the player is paused
if (player.paused()) {
return resetMonitor();
}
// playback isn't expected once the video has ended
if (player.ended()) {
return resetMonitor();
}
if (!options.progressDisabled) {
healthcheck('progress', resetMonitor);
}
};
fn.call(this);
var onPlayNoSource = function onPlayNoSource() {
if (!player.currentSrc()) {
player.error({
code: -1,
type: 'PLAYER_ERR_NO_SRC'
});
}
};
player.on(type, check);
listeners.push([type, check]);
};
var onErrorHandler = function onErrorHandler() {
var details = '';
var error = player.error();
var content = document.createElement('div');
var dialogContent = '';
var onPlayStartMonitor = function onPlayStartMonitor() {
var lastTime = 0;
// In the rare case when `error()` does not return an error object,
// defensively escape the handler function.
if (!error) {
return;
}
cleanup();
error = videojs.mergeOptions(error, options.errors[error.code || error.type || 0]);
// if no playback is detected for long enough, trigger a timeout error
resetMonitor();
healthcheck(['timeupdate', 'adtimeupdate'], function () {
var currentTime = player.currentTime();
if (error.message) {
details = '<div class="vjs-errors-details">' + player.localize('Technical details') + '\n : <div class="vjs-errors-message">' + player.localize(error.message) + '</div>\n </div>';
}
// playback is operating normally or has recovered
if (currentTime !== lastTime) {
lastTime = currentTime;
resetMonitor();
if (error.code === 4 && FlashObj && !FlashObj.isSupported()) {
var flashMessage = player.localize('If you are using an older browser please try upgrading or installing Flash.');
details += '<span class="vjs-errors-flashmessage">' + flashMessage + '</span>';
}
});
if (!options.progressDisabled) {
healthcheck('progress', resetMonitor);
}
};
var display = player.getChild('errorDisplay');
var onPlayNoSource = function onPlayNoSource() {
if (!player.currentSrc()) {
player.error({
code: -1,
type: 'PLAYER_ERR_NO_SRC'
});
}
};
content.className = 'vjs-errors-dialog';
content.id = 'vjs-errors-dialog';
dialogContent = '<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">' + this.localize(error.headline) + '</h2>\n <div><b>' + this.localize('Error Code') + '</b>: ' + (error.type || error.code) + '</div>\n ' + details + '\n </div>';
var onErrorHandler = function onErrorHandler() {
var details = '';
var error = player.error();
var content = document_1.createElement('div');
var dialogContent = '';
var closeable = display.closeable(!('dismiss' in error) || error.dismiss);
// In the rare case when `error()` does not return an error object,
// defensively escape the handler function.
if (!error) {
return;
}
// We should get a close button
if (closeable) {
dialogContent += '<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">' + this.localize('OK') + '</button>\n </div>';
content.innerHTML = dialogContent;
display.fillWith(content);
// Get the close button inside the error display
display.contentEl().firstChild.appendChild(display.getChild('closeButton').el());
error = videojs.mergeOptions(error, options.errors[error.code || error.type || 0]);
var okButton = display.el().querySelector('.vjs-errors-ok-button');
if (error.message) {
details = '<div class="vjs-errors-details">' + player.localize('Technical details') + '\n : <div class="vjs-errors-message">' + player.localize(error.message) + '</div>\n </div>';
}
player.on(okButton, 'click', function () {
display.close();
});
} else {
content.innerHTML = dialogContent;
display.fillWith(content);
}
if (error.code === 4 && FlashObj && !FlashObj.isSupported()) {
var flashMessage = player.localize('If you are using an older browser please try upgrading or installing Flash.');
if (player.currentWidth() <= 600 || player.currentHeight() <= 250) {
display.addClass('vjs-xs');
}
details += '<span class="vjs-errors-flashmessage">' + flashMessage + '</span>';
}
display.one('modalclose', function () {
return player.error(null);
});
};
var display = player.getChild('errorDisplay');
var onDisposeHandler = function onDisposeHandler() {
cleanup();
content.className = 'vjs-errors-dialog';
content.id = 'vjs-errors-dialog';
dialogContent = '<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">' + this.localize(error.headline) + '</h2>\n <div><b>' + this.localize('Error Code') + '</b>: ' + (error.type || error.code) + '</div>\n ' + details + '\n </div>';
player.removeClass('vjs-errors');
player.off('play', onPlayStartMonitor);
player.off('play', onPlayNoSource);
player.off('dispose', onDisposeHandler);
player.off(['aderror', 'error'], onErrorHandler);
};
var closeable = display.closeable(!('dismiss' in error) || error.dismiss);
var reInitPlugin = function reInitPlugin(newOptions) {
onDisposeHandler();
initPlugin(player, videojs.mergeOptions(defaults, newOptions));
};
// We should get a close button
if (closeable) {
dialogContent += '<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">' + this.localize('OK') + '</button>\n </div>';
content.innerHTML = dialogContent;
display.fillWith(content);
// Get the close button inside the error display
display.contentEl().firstChild.appendChild(display.getChild('closeButton').el());
reInitPlugin.extend = function (errors) {
return updateErrors(errors);
};
reInitPlugin.getAll = function () {
return videojs.mergeOptions(options.errors);
};
var okButton = display.el().querySelector('.vjs-errors-ok-button');
// 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();
}
}
};
player.on(okButton, 'click', function () {
display.close();
});
} else {
content.innerHTML = dialogContent;
display.fillWith(content);
}
reInitPlugin.disableProgress = function (disabled) {
options.progressDisabled = disabled;
onPlayStartMonitor();
};
if (player.currentWidth() <= 600 || player.currentHeight() <= 250) {
display.addClass('vjs-xs');
}
player.on('play', onPlayStartMonitor);
player.on('play', onPlayNoSource);
player.on('dispose', onDisposeHandler);
player.on(['aderror', 'error'], onErrorHandler);
display.one('modalclose', function () {
return player.error(null);
player.ready(function () {
player.addClass('vjs-errors');
});
};
var onDisposeHandler = function onDisposeHandler() {
cleanup();
// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
player.removeClass('vjs-errors');
player.off('play', onPlayStartMonitor);
player.off('play', onPlayNoSource);
player.off('dispose', onDisposeHandler);
player.off(['aderror', 'error'], onErrorHandler);
};
// Include the version number.
reInitPlugin.VERSION = version;
var reInitPlugin = function reInitPlugin(newOptions) {
onDisposeHandler();
initPlugin(player, videojs.mergeOptions(defaults, newOptions));
player.errors = reInitPlugin;
};
reInitPlugin.extend = function (errors) {
return updateErrors(errors);
var errors = function errors(options) {
initPlugin(this, videojs.mergeOptions(defaults, options));
};
reInitPlugin.getAll = function () {
return videojs.mergeOptions(options.errors);
};
// 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) {
options.progressDisabled = disabled;
onPlayStartMonitor();
};
player.on('play', onPlayStartMonitor);
player.on('play', onPlayNoSource);
player.on('dispose', onDisposeHandler);
player.on(['aderror', 'error'], onErrorHandler);
player.ready(function () {
player.addClass('vjs-errors');
['extend', 'getAll', 'disableProgress'].forEach(function (k) {
errors[k] = function () {
videojs.log.warn('The errors.' + k + '() method is not available until the plugin has been initialized!');
};
});
// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
// Include the version number.
reInitPlugin.VERSION = version;
errors.VERSION = version;
player.errors = reInitPlugin;
};
// Register the plugin with video.js.
registerPlugin('errors', errors);
var errors = function errors(options) {
initPlugin(this, videojs.mergeOptions(defaults, options));
};
return errors;
['extend', 'getAll', 'disableProgress'].forEach(function (k) {
errors[k] = function () {
videojs.log.warn('The errors.' + k + '() method is not available until the plugin has been initialized!');
};
});
// Include the version number.
errors.VERSION = version;
// Register the plugin with video.js.
registerPlugin('errors', errors);
return errors;
})));

@@ -1,7 +0,2 @@

/**
* videojs-errors
* @version 4.1.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:{},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(),_.VERSION="4.1.0",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!")}}),f.VERSION="4.1.0",c("errors",f),f});
/*! @name videojs-errors @version 4.1.1 @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.videojsErrors=r(e.videojs,e.document)}(this,function(e,r){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,r=r&&r.hasOwnProperty("default")?r.default:r;var o=e.getComponent("Flash"),i=!e.browser.IS_IPHONE,n=e.registerPlugin||e.plugin,t={header:"",code:"",message:"",timeout:45e3,dismiss:i,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."}}},s=function(i){!function i(n,s){var a=void 0,d=void 0,l=void 0,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 p=function(){n.clearTimeout(d),l&&(l=!1,n.removeClass("vjs-waiting")),d=n.setTimeout(function(){n.error()||n.paused()||n.ended()||(l=!0,n.addClass("vjs-waiting"))},1e3),n.clearTimeout(a),a=n.setTimeout(function(){n.error()||n.paused()||n.ended()||n.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})},s.timeout),n.error()&&-2===n.error().code&&n.error(null)},f=function(){for(var e=void 0;c.length;)e=c.shift(),n.off(e[0],e[1]);n.clearTimeout(a),n.clearTimeout(d)},h=function(e,r){var o=function(){if(!n.error()){var e=n.$(".vjs-tech");if(e&&"application/x-shockwave-flash"===e.type&&!e.vjs_getProperty)return void n.error({code:-2,type:"PLAYER_ERR_TIMEOUT"});if(n.paused())return p();if(n.ended())return p()}r.call(this)};n.on(e,o),c.push([e,o])},v=function(){var e=0;f(),p(),h(["timeupdate","adtimeupdate"],function(){var r=n.currentTime();r!==e&&(e=r,p())}),s.progressDisabled||h("progress",p)},E=function(){n.currentSrc()||n.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},R=function(){var i="",t=n.error(),a=r.createElement("div"),d="";if(t){(t=e.mergeOptions(t,s.errors[t.code||t.type||0])).message&&(i='<div class="vjs-errors-details">'+n.localize("Technical details")+'\n : <div class="vjs-errors-message">'+n.localize(t.message)+"</div>\n </div>"),4===t.code&&o&&!o.isSupported()&&(i+='<span class="vjs-errors-flashmessage">'+n.localize("If you are using an older browser please try upgrading or installing Flash.")+"</span>");var l=n.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(t.headline)+"</h2>\n <div><b>"+this.localize("Error Code")+"</b>: "+(t.type||t.code)+"</div>\n "+i+"\n </div>",l.closeable(!("dismiss"in t)||t.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");n.on(c,"click",function(){l.close()})}else a.innerHTML=d,l.fillWith(a);(n.currentWidth()<=600||n.currentHeight()<=250)&&l.addClass("vjs-xs"),l.one("modalclose",function(){return n.error(null)})}},m=function e(){f(),n.removeClass("vjs-errors"),n.off("play",v),n.off("play",E),n.off("dispose",e),n.off(["aderror","error"],R)},g=function(r){m(),i(n,e.mergeOptions(t,r))};g.extend=function(e){return u(e)},g.getAll=function(){return e.mergeOptions(s.errors)},g.timeout=function(e){if(void 0===e)return s.timeout;e!==s.timeout&&(s.timeout=e,n.paused()||v())},g.disableProgress=function(e){s.progressDisabled=e,v()},n.on("play",v),n.on("play",E),n.on("dispose",m),n.on(["aderror","error"],R),n.ready(function(){n.addClass("vjs-errors")}),n.paused()||v(),g.VERSION="4.1.1",n.errors=g}(this,e.mergeOptions(t,i))};return["extend","getAll","disableProgress"].forEach(function(r){s[r]=function(){e.log.warn("The errors."+r+"() method is not available until the plugin has been initialized!")}}),s.VERSION="4.1.1",n("errors",s),s});
{
"name": "videojs-errors",
"version": "4.1.0",
"version": "4.1.1",
"author": "Brightcove, Inc.",

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

"module": "dist/videojs-errors.es.js",
"engines": {
"node": ">=4.4.0"
},
"repository": {

@@ -18,6 +15,2 @@ "type": "git",

"keywords": [
"flash",
"html5",
"player",
"video",
"videojs",

@@ -27,3 +20,3 @@ "videojs-plugin"

"generator-videojs-plugin": {
"version": "5.0.0-7"
"version": "6.1.1"
},

@@ -33,33 +26,24 @@ "scripts": {

"build": "npm-run-all -p build:*",
"build:css": "npm-run-all build:css:sass build:css:bannerize",
"build:css:bannerize": "bannerize dist/videojs-errors.css --banner=scripts/banner.ejs",
"build:css:sass": "node-sass src/plugin.scss dist/videojs-errors.css --output-style=compressed --linefeed=lf",
"build:js": "npm-run-all build:js:rollup-modules build:js:rollup-umd build:js:bannerize build:js:uglify",
"build:js:bannerize": "bannerize dist/videojs-errors.js --banner=scripts/banner.ejs",
"build:js:rollup-modules": "rollup -c scripts/modules.rollup.config.js",
"build:js:rollup-umd": "rollup -c scripts/umd.rollup.config.js",
"build:js:uglify": "uglifyjs dist/videojs-errors.js --comments --mangle --compress --ie8 -o dist/videojs-errors.min.js",
"build:css": "node-sass src/plugin.scss dist/videojs-errors.css --output-style=compressed --linefeed=lf",
"build:css:postcss": "postcss --verbose -o dist/videojs-errors.css --config scripts/postcss.config.js src/plugin.css",
"build:js": "rollup -c scripts/rollup.config.js",
"build:lang": "vjslang --dir dist/lang",
"build:test": "rollup -c scripts/test.rollup.config.js",
"clean": "rimraf dist test/dist",
"postclean": "mkdirp dist test/dist",
"docs": "npm-run-all docs:*",
"docs:api": "jsdoc src -r -c jsdoc.json -d docs/api",
"docs:api": "jsdoc src -r -c scripts/jsdoc.json -d docs/api",
"docs:toc": "doctoc README.md",
"lint": "vjsstandard",
"prestart": "npm run build",
"start": "npm-run-all -p start:server watch",
"start:server": "static -a 0.0.0.0 -p 9999 -H '{\"Cache-Control\": \"no-cache, must-revalidate\"}' .",
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch --no-browsers",
"start": "npm-run-all -p server watch",
"pretest": "npm-run-all lint build",
"test": "karma start test/karma.conf.js",
"test": "karma start scripts/karma.conf.js",
"preversion": "npm test",
"version": "node scripts/version.js",
"watch": "npm-run-all -p watch:*",
"watch:css": "node-sass src/plugin.scss dist/videojs-errors.css --output-style=compressed --linefeed=lf --watch src/**/*.scss",
"watch:js-modules": "rollup -c scripts/modules.rollup.config.js -w",
"watch:js-umd": "rollup -c scripts/umd.rollup.config.js -w",
"watch:test": "rollup -c scripts/test.rollup.config.js -w",
"prepublish": "npm run build",
"watch:css": "npm run build:css -- -w",
"watch:js": "npm run build:js -- -w",
"prepublish": "not-in-install && npm run build || in-install",
"prepush": "npm run lint",
"precommit": "npm run docs && git add README.md"
"precommit": "npm run docs:toc && git add README.md"
},

@@ -70,5 +54,3 @@ "vjsstandard": {

"docs",
"scripts",
"test/dist",
"test/karma.conf.js"
"test/dist"
]

@@ -87,44 +69,55 @@ },

"global": "^4.3.2",
"video.js": "^6.8.0 || ^7.0.0"
"video.js": "^6 || ^7"
},
"devDependencies": {
"autoprefixer": "^8.6.0",
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-preset-es2015": "^6.14.0",
"babel-preset-es3": "^1.0.1",
"bannerize": "^1.0.2",
"conventional-changelog-cli": "^1.3.1",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-env": "^1.7.0",
"conventional-changelog-cli": "^2.0.0",
"conventional-changelog-videojs": "^3.0.0",
"doctoc": "^1.3.0",
"es5-shim": "^4.5.9",
"husky": "^0.13.3",
"cssnano": "^3.10.0",
"doctoc": "^1.3.1",
"husky": "^0.14.3",
"in-publish": "^2.0.0",
"jsdoc": "^3.4.3",
"karma": "~1.3.0",
"karma-chrome-launcher": "^2.1.1",
"karma-detect-browsers": "^2.2.5",
"karma-firefox-launcher": "^1.0.1",
"karma": "^2.0.2",
"karma-browserstack-launcher": "^1.3.0",
"karma-chrome-launcher": "^2.2.0",
"karma-detect-browsers": "^2.2.6",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-qunit": "^1.2.1",
"karma-qunit": "^2.0.0",
"karma-safari-launcher": "^1.0.0",
"karma-safaritechpreview-launcher": "0.0.6",
"karma-teamcity-reporter": "^1.1.0",
"mkdirp": "^0.5.1",
"node-sass": "^4.5.3",
"node-static": "^0.7.9",
"npm-run-all": "^4.0.2",
"qunitjs": "^1.21.0",
"npm-run-all": "^4.1.2",
"postcss-banner": "^3.0.0",
"postcss-cli": "^5.0.0",
"postcss-import": "^11.1.0",
"postcss-preset-env": "^5.1.0",
"qunit": "^2.5.1",
"rimraf": "^2.6.1",
"rollup": "^0.51.0",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-json": "^2.1.1",
"rollup-plugin-multi-entry": "^2.0.1",
"rollup": "^0.60.1",
"rollup-plugin-babel": "^3.0.4",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-multi-entry": "^2.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-replace": "^1.1.1",
"rollup-watch": "^3.2.2",
"semver": "^5.3.0",
"sinon": "^2.2.0",
"uglify-js": "^3.0.7",
"rollup-plugin-uglify": "^4.0.0",
"semver": "^5.1.0",
"serve-static": "^1.13.2",
"sinon": "^5.1.0",
"uglify-es": "^3.3.9",
"videojs-languages": "^1.0.0",
"videojs-standard": "^6.0.0"
}
},
"browserslist": [
"defaults",
"ie 11"
]
}
# videojs-errors
[![Build Status](https://travis-ci.org/brightcove/videojs-errors.svg?branch=master)](https://travis-ci.org/brightcove/videojs-errors)
[![Greenkeeper badge](https://badges.greenkeeper.io/brightcove/videojs-errors.svg)](https://greenkeeper.io/)
[![Slack Status](http://slack.videojs.com/badge.svg)](http://slack.videojs.com)
[![NPM](https://nodei.co/npm/videojs-errors.png?downloads=true&downloadRank=true)](https://nodei.co/npm/videojs-errors/)
A plugin that displays user-friendly messages when Video.js encounters an error.
### Table of Contents
Maintenance Status: Stable

@@ -171,3 +175,3 @@ <!-- START doctoc generated TOC please keep comment here to allow auto update -->

If no argument is passed, the current timeout value is returned.
If no argument is passed, the current timeout value is returned.

@@ -174,0 +178,0 @@ ## Known Issues

@@ -1,999 +0,998 @@

(function (QUnit,sinon,videojs) {
'use strict';
(function (videojs,QUnit,sinon) {
'use strict';
QUnit = QUnit && QUnit.hasOwnProperty('default') ? QUnit['default'] : QUnit;
sinon = sinon && sinon.hasOwnProperty('default') ? sinon['default'] : sinon;
videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs;
videojs = videojs && videojs.hasOwnProperty('default') ? videojs['default'] : videojs;
QUnit = QUnit && QUnit.hasOwnProperty('default') ? QUnit['default'] : QUnit;
sinon = sinon && sinon.hasOwnProperty('default') ? sinon['default'] : sinon;
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var empty = {};
var empty = {};
var empty$1 = /*#__PURE__*/Object.freeze({
default: empty
});
var empty$1 = (Object.freeze || Object)({
'default': empty
});
var minDoc = ( empty$1 && empty ) || empty$1;
var minDoc = ( empty$1 && empty ) || empty$1;
var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
typeof window !== 'undefined' ? window : {};
var topLevel = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal :
typeof window !== 'undefined' ? window : {};
var doccy;
var doccy;
if (typeof document !== 'undefined') {
doccy = document;
} else {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
if (typeof document !== 'undefined') {
doccy = document;
} else {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'];
if (!doccy) {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
}
}
if (!doccy) {
doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc;
}
}
var document_1 = doccy;
var document_1 = doccy;
var version = "4.1.1";
var version = "4.1.0";
var FlashObj = videojs.getComponent('Flash');
var defaultDismiss = !videojs.browser.IS_IPHONE;
var FlashObj = videojs.getComponent('Flash');
var defaultDismiss = !videojs.browser.IS_IPHONE;
// Video.js 5/6 cross-compatibility.
var registerPlugin = videojs.registerPlugin || videojs.plugin;
// Video.js 5/6 cross-compatibility.
var registerPlugin = videojs.registerPlugin || videojs.plugin;
// Default options for the plugin.
var defaults = {
header: '',
code: '',
message: '',
timeout: 45 * 1000,
dismiss: defaultDismiss,
progressDisabled: false,
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.'
}
}
};
// Default options for the plugin.
var defaults = {
header: '',
code: '',
message: '',
timeout: 45 * 1000,
dismiss: defaultDismiss,
progressDisabled: false,
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.'
}
}
};
var initPlugin = function initPlugin(player, options) {
var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];
var initPlugin = function initPlugin(player, options) {
var monitor = void 0;
var waiting = void 0;
var isStalling = void 0;
var listeners = [];
var updateErrors = function updateErrors(updates) {
options.errors = videojs.mergeOptions(options.errors, updates);
var updateErrors = function updateErrors(updates) {
options.errors = videojs.mergeOptions(options.errors, updates);
// Create `code`s from errors which don't have them (based on their keys).
Object.keys(options.errors).forEach(function (k) {
var err = options.errors[k];
// Create `code`s from errors which don't have them (based on their keys).
Object.keys(options.errors).forEach(function (k) {
var err = options.errors[k];
if (!err.type) {
err.type = k;
}
});
};
if (!err.type) {
err.type = k;
}
});
};
// Make sure we flesh out initially-provided errors.
updateErrors();
// Make sure we flesh out initially-provided errors.
updateErrors();
// clears the previous monitor timeout and sets up a new one
var resetMonitor = function resetMonitor() {
// at this point the player has recovered
player.clearTimeout(waiting);
if (isStalling) {
isStalling = false;
player.removeClass('vjs-waiting');
}
// clears the previous monitor timeout and sets up a new one
var resetMonitor = function resetMonitor() {
// 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
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
// start the loading spinner if player has stalled
waiting = player.setTimeout(function () {
// player already has an error
// or is not playing under normal conditions
if (player.error() || player.paused() || player.ended()) {
return;
}
isStalling = true;
player.addClass('vjs-waiting');
}, 1000);
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.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({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
}, options.timeout);
player.error({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
}, options.timeout);
// clear out any existing player timeout
// playback has recovered
if (player.error() && player.error().code === -2) {
player.error(null);
}
};
// clear out any existing player timeout
// playback has recovered
if (player.error() && player.error().code === -2) {
player.error(null);
}
};
// clear any previously registered listeners
var cleanup = function cleanup() {
var listener = void 0;
// clear any previously registered listeners
var cleanup = function cleanup() {
var listener = void 0;
while (listeners.length) {
listener = listeners.shift();
player.off(listener[0], listener[1]);
}
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};
while (listeners.length) {
listener = listeners.shift();
player.off(listener[0], listener[1]);
}
player.clearTimeout(monitor);
player.clearTimeout(waiting);
};
// creates and tracks a player listener if the player looks alive
var healthcheck = function healthcheck(type, fn) {
var check = function check() {
// if there's an error do not reset the monitor and
// clear the error unless time is progressing
if (!player.error()) {
// error if using Flash and its API is unavailable
var tech = player.$('.vjs-tech');
// creates and tracks a player listener if the player looks alive
var healthcheck = function healthcheck(type, fn) {
var check = function check() {
// if there's an error do not reset the monitor and
// clear the error unless time is progressing
if (!player.error()) {
// error if using Flash and its API is unavailable
var tech = player.$('.vjs-tech');
if (tech && tech.type === 'application/x-shockwave-flash' && !tech.vjs_getProperty) {
player.error({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
return;
}
if (tech && tech.type === 'application/x-shockwave-flash' && !tech.vjs_getProperty) {
player.error({
code: -2,
type: 'PLAYER_ERR_TIMEOUT'
});
return;
}
// playback isn't expected if the player is paused
if (player.paused()) {
return resetMonitor();
}
// playback isn't expected once the video has ended
if (player.ended()) {
return resetMonitor();
}
}
// playback isn't expected if the player is paused
if (player.paused()) {
return resetMonitor();
}
// playback isn't expected once the video has ended
if (player.ended()) {
return resetMonitor();
}
}
fn.call(this);
};
fn.call(this);
};
player.on(type, check);
listeners.push([type, check]);
};
player.on(type, check);
listeners.push([type, check]);
};
var onPlayStartMonitor = function onPlayStartMonitor() {
var lastTime = 0;
var onPlayStartMonitor = function onPlayStartMonitor() {
var lastTime = 0;
cleanup();
cleanup();
// if no playback is detected for long enough, trigger a timeout error
resetMonitor();
healthcheck(['timeupdate', 'adtimeupdate'], function () {
var currentTime = player.currentTime();
// if no playback is detected for long enough, trigger a timeout error
resetMonitor();
healthcheck(['timeupdate', 'adtimeupdate'], function () {
var currentTime = player.currentTime();
// playback is operating normally or has recovered
if (currentTime !== lastTime) {
lastTime = currentTime;
resetMonitor();
}
});
// playback is operating normally or has recovered
if (currentTime !== lastTime) {
lastTime = currentTime;
resetMonitor();
}
});
if (!options.progressDisabled) {
healthcheck('progress', resetMonitor);
}
};
if (!options.progressDisabled) {
healthcheck('progress', resetMonitor);
}
};
var onPlayNoSource = function onPlayNoSource() {
if (!player.currentSrc()) {
player.error({
code: -1,
type: 'PLAYER_ERR_NO_SRC'
});
}
};
var onPlayNoSource = function onPlayNoSource() {
if (!player.currentSrc()) {
player.error({
code: -1,
type: 'PLAYER_ERR_NO_SRC'
});
}
};
var onErrorHandler = function onErrorHandler() {
var details = '';
var error = player.error();
var content = document_1.createElement('div');
var dialogContent = '';
var onErrorHandler = function onErrorHandler() {
var details = '';
var error = player.error();
var content = document_1.createElement('div');
var dialogContent = '';
// In the rare case when `error()` does not return an error object,
// defensively escape the handler function.
if (!error) {
return;
}
// In the rare case when `error()` does not return an error object,
// defensively escape the handler function.
if (!error) {
return;
}
error = videojs.mergeOptions(error, options.errors[error.code || error.type || 0]);
error = videojs.mergeOptions(error, options.errors[error.code || error.type || 0]);
if (error.message) {
details = '<div class="vjs-errors-details">' + player.localize('Technical details') + '\n : <div class="vjs-errors-message">' + player.localize(error.message) + '</div>\n </div>';
}
if (error.message) {
details = '<div class="vjs-errors-details">' + player.localize('Technical details') + '\n : <div class="vjs-errors-message">' + player.localize(error.message) + '</div>\n </div>';
}
if (error.code === 4 && FlashObj && !FlashObj.isSupported()) {
var flashMessage = player.localize('If you are using an older browser please try upgrading or installing Flash.');
if (error.code === 4 && FlashObj && !FlashObj.isSupported()) {
var flashMessage = player.localize('If you are using an older browser please try upgrading or installing Flash.');
details += '<span class="vjs-errors-flashmessage">' + flashMessage + '</span>';
}
details += '<span class="vjs-errors-flashmessage">' + flashMessage + '</span>';
}
var display = player.getChild('errorDisplay');
var display = player.getChild('errorDisplay');
content.className = 'vjs-errors-dialog';
content.id = 'vjs-errors-dialog';
dialogContent = '<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">' + this.localize(error.headline) + '</h2>\n <div><b>' + this.localize('Error Code') + '</b>: ' + (error.type || error.code) + '</div>\n ' + details + '\n </div>';
content.className = 'vjs-errors-dialog';
content.id = 'vjs-errors-dialog';
dialogContent = '<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">' + this.localize(error.headline) + '</h2>\n <div><b>' + this.localize('Error Code') + '</b>: ' + (error.type || error.code) + '</div>\n ' + details + '\n </div>';
var closeable = display.closeable(!('dismiss' in error) || error.dismiss);
var closeable = display.closeable(!('dismiss' in error) || error.dismiss);
// We should get a close button
if (closeable) {
dialogContent += '<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">' + this.localize('OK') + '</button>\n </div>';
content.innerHTML = dialogContent;
display.fillWith(content);
// Get the close button inside the error display
display.contentEl().firstChild.appendChild(display.getChild('closeButton').el());
// We should get a close button
if (closeable) {
dialogContent += '<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">' + this.localize('OK') + '</button>\n </div>';
content.innerHTML = dialogContent;
display.fillWith(content);
// Get the close button inside the error display
display.contentEl().firstChild.appendChild(display.getChild('closeButton').el());
var okButton = display.el().querySelector('.vjs-errors-ok-button');
var okButton = display.el().querySelector('.vjs-errors-ok-button');
player.on(okButton, 'click', function () {
display.close();
});
} else {
content.innerHTML = dialogContent;
display.fillWith(content);
}
player.on(okButton, 'click', function () {
display.close();
});
} else {
content.innerHTML = dialogContent;
display.fillWith(content);
}
if (player.currentWidth() <= 600 || player.currentHeight() <= 250) {
display.addClass('vjs-xs');
}
if (player.currentWidth() <= 600 || player.currentHeight() <= 250) {
display.addClass('vjs-xs');
}
display.one('modalclose', function () {
return player.error(null);
});
};
display.one('modalclose', function () {
return player.error(null);
});
};
var onDisposeHandler = function onDisposeHandler() {
cleanup();
var onDisposeHandler = function onDisposeHandler() {
cleanup();
player.removeClass('vjs-errors');
player.off('play', onPlayStartMonitor);
player.off('play', onPlayNoSource);
player.off('dispose', onDisposeHandler);
player.off(['aderror', 'error'], onErrorHandler);
};
player.removeClass('vjs-errors');
player.off('play', onPlayStartMonitor);
player.off('play', onPlayNoSource);
player.off('dispose', onDisposeHandler);
player.off(['aderror', 'error'], onErrorHandler);
};
var reInitPlugin = function reInitPlugin(newOptions) {
onDisposeHandler();
initPlugin(player, videojs.mergeOptions(defaults, newOptions));
};
var reInitPlugin = function reInitPlugin(newOptions) {
onDisposeHandler();
initPlugin(player, videojs.mergeOptions(defaults, newOptions));
};
reInitPlugin.extend = function (errors) {
return updateErrors(errors);
};
reInitPlugin.getAll = function () {
return videojs.mergeOptions(options.errors);
};
reInitPlugin.extend = function (errors) {
return updateErrors(errors);
};
reInitPlugin.getAll = function () {
return videojs.mergeOptions(options.errors);
};
// 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();
}
}
};
// 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) {
options.progressDisabled = disabled;
onPlayStartMonitor();
};
reInitPlugin.disableProgress = function (disabled) {
options.progressDisabled = disabled;
onPlayStartMonitor();
};
player.on('play', onPlayStartMonitor);
player.on('play', onPlayNoSource);
player.on('dispose', onDisposeHandler);
player.on(['aderror', 'error'], onErrorHandler);
player.on('play', onPlayStartMonitor);
player.on('play', onPlayNoSource);
player.on('dispose', onDisposeHandler);
player.on(['aderror', 'error'], onErrorHandler);
player.ready(function () {
player.addClass('vjs-errors');
});
player.ready(function () {
player.addClass('vjs-errors');
});
// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
// if the plugin is re-initialised during playback, start the timeout handler.
if (!player.paused()) {
onPlayStartMonitor();
}
// Include the version number.
reInitPlugin.VERSION = version;
// Include the version number.
reInitPlugin.VERSION = version;
player.errors = reInitPlugin;
};
player.errors = reInitPlugin;
};
var errors = function errors(options) {
initPlugin(this, videojs.mergeOptions(defaults, options));
};
var errors = function errors(options) {
initPlugin(this, videojs.mergeOptions(defaults, options));
};
['extend', 'getAll', 'disableProgress'].forEach(function (k) {
errors[k] = function () {
videojs.log.warn('The errors.' + k + '() method is not available until the plugin has been initialized!');
};
});
['extend', 'getAll', 'disableProgress'].forEach(function (k) {
errors[k] = function () {
videojs.log.warn('The errors.' + k + '() method is not available until the plugin has been initialized!');
};
});
// Include the version number.
errors.VERSION = version;
// Include the version number.
errors.VERSION = version;
// Register the plugin with video.js.
registerPlugin('errors', errors);
// Register the plugin with video.js.
registerPlugin('errors', errors);
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var Player = videojs.getComponent('Player');
var Player = videojs.getComponent('Player');
var sources = [{
src: 'movie.mp4',
type: 'video/mp4'
}, {
src: 'movie.webm',
type: 'video/webm'
}];
var sources = [{
src: 'movie.mp4',
type: 'video/mp4'
}, {
src: 'movie.webm',
type: 'video/webm'
}];
QUnit.test('the environment is sane', function (assert) {
assert.strictEqual(_typeof(Array.isArray), 'function', 'es5 exists');
assert.strictEqual(typeof sinon === 'undefined' ? 'undefined' : _typeof(sinon), 'object', 'sinon exists');
assert.strictEqual(typeof videojs === 'undefined' ? 'undefined' : _typeof(videojs), 'function', 'videojs exists');
assert.strictEqual(typeof errors === 'undefined' ? 'undefined' : _typeof(errors), 'function', 'plugin is a function');
});
QUnit.test('the environment is sane', function (assert) {
assert.strictEqual(_typeof(Array.isArray), 'function', 'es5 exists');
assert.strictEqual(typeof sinon === 'undefined' ? 'undefined' : _typeof(sinon), 'object', 'sinon exists');
assert.strictEqual(typeof videojs === 'undefined' ? 'undefined' : _typeof(videojs), 'function', 'videojs exists');
assert.strictEqual(typeof errors === 'undefined' ? 'undefined' : _typeof(errors), 'function', 'plugin is a function');
});
QUnit.module('videojs-errors', {
beforeEach: function beforeEach() {
QUnit.module('videojs-errors', {
beforeEach: function beforeEach() {
// Mock the environment's timers because certain things - particularly
// player readiness - are asynchronous in video.js 5.
this.clock = sinon.useFakeTimers();
this.fixture = document_1.getElementById('qunit-fixture');
this.video = document_1.createElement('video');
this.fixture.appendChild(this.video);
this.player = videojs(this.video);
// Mock the environment's timers because certain things - particularly
// player readiness - are asynchronous in video.js 5.
this.clock = sinon.useFakeTimers();
this.fixture = document_1.getElementById('qunit-fixture');
this.video = document_1.createElement('video');
this.fixture.appendChild(this.video);
this.player = videojs(this.video);
this.player.buffered = function () {
return videojs.createTimeRange(0, 0);
};
this.player.paused = function () {
return false;
};
this.player.pause = function () {
return false;
};
this.player.buffered = function () {
return videojs.createTimeRange(0, 0);
};
this.player.paused = function () {
return false;
};
this.player.pause = function () {
return false;
};
// initialize the plugin with the default options
this.player.errors();
this.errorDisplay = this.player.getChild('errorDisplay');
// initialize the plugin with the default options
this.player.errors();
this.errorDisplay = this.player.getChild('errorDisplay');
// Tick forward so the player is ready.
this.clock.tick(1);
},
afterEach: function afterEach() {
this.player.dispose();
this.clock.restore();
}
});
// Tick forward so the player is ready.
this.clock.tick(1);
},
afterEach: function afterEach() {
this.player.dispose();
this.clock.restore();
}
});
QUnit.test('registers itself with video.js', function (assert) {
assert.expect(2);
QUnit.test('registers itself with video.js', function (assert) {
assert.expect(2);
assert.strictEqual(_typeof(Player.prototype.errors), 'function', 'videojs-errors plugin was registered');
assert.strictEqual(_typeof(Player.prototype.errors), 'function', 'videojs-errors plugin was registered');
this.player.errors();
this.player.errors();
// Tick the clock forward enough to trigger the player to be "ready".
this.clock.tick(1);
// Tick the clock forward enough to trigger the player to be "ready".
this.clock.tick(1);
assert.ok(this.player.hasClass('vjs-errors'), 'the plugin adds a class to the player');
});
assert.ok(this.player.hasClass('vjs-errors'), 'the plugin adds a class to the player');
});
QUnit.test('play() without a src is an error', function (assert) {
var errors$$1 = 0;
QUnit.test('play() without a src is an error', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.trigger('play');
this.player.on('error', function () {
errors$$1++;
});
this.player.trigger('play');
assert.strictEqual(errors$$1, 1, 'emitted an error');
assert.strictEqual(this.player.error().code, -1, 'error code is -1');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_NO_SRC', 'error type is no source');
});
assert.strictEqual(errors$$1, 1, 'emitted an error');
assert.strictEqual(this.player.error().code, -1, 'error code is -1');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_NO_SRC', 'error type is no source');
});
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);
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');
});
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');
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');
});
// 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) {
var errors$$1 = 0;
QUnit.test('no progress for 45 seconds is an error', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
this.clock.tick(45 * 1000);
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
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');
});
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('when progress watching is disabled, progress within 45 seconds is an error', function (assert) {
var errors$$1 = 0;
QUnit.test('when progress watching is disabled, progress within 45 seconds is an error', function (assert) {
var errors$$1 = 0;
this.player.errors.disableProgress(true);
this.player.errors.disableProgress(true);
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
this.clock.tick(40 * 1000);
this.player.trigger('progress');
this.clock.tick(5 * 1000);
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
this.clock.tick(40 * 1000);
this.player.trigger('progress');
this.clock.tick(5 * 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');
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');
this.player.errors.disableProgress(false);
});
this.player.errors.disableProgress(false);
});
QUnit.test('Flash API is unavailable when using Flash is an error', function (assert) {
this.player.tech_.el_.type = 'application/x-shockwave-flash';
// when Flash dies the object methods go away
/* eslint-disable camelcase */
this.player.tech_.el_.vjs_getProperty = null;
/* eslint-enable camelcase */
this.player.paused = function () {
return true;
};
QUnit.test('Flash API is unavailable when using Flash is an error', function (assert) {
this.player.tech_.el_.type = 'application/x-shockwave-flash';
// when Flash dies the object methods go away
/* eslint-disable camelcase */
this.player.tech_.el_.vjs_getProperty = null;
/* eslint-enable camelcase */
this.player.paused = function () {
return true;
};
var errors$$1 = 0;
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
this.player.trigger('timeupdate');
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
this.player.trigger('timeupdate');
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');
});
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('the plugin cleans up after its previous incarnation when called again', function (assert) {
var errors$$1 = 0;
QUnit.test('the plugin cleans up after its previous incarnation when called again', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
return errors$$1++;
});
this.player.on('error', function () {
return errors$$1++;
});
// Call plugin multiple times
this.player.errors();
this.player.errors();
// Call plugin multiple times
this.player.errors();
this.player.errors();
// Tick the clock forward enough to trigger the player to be "ready".
this.clock.tick(1);
// Tick the clock forward enough to trigger the player to be "ready".
this.clock.tick(1);
this.player.trigger('play');
this.player.trigger('play');
assert.strictEqual(errors$$1, 1, 'emitted a single error');
assert.strictEqual(this.player.error().code, -1, 'error code is -1');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_NO_SRC');
});
assert.strictEqual(errors$$1, 1, 'emitted a single error');
assert.strictEqual(this.player.error().code, -1, 'error code is -1');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_NO_SRC');
});
QUnit.test('when dispose is triggered should not throw error ', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.player.dispose();
this.clock.tick(45 * 1000);
QUnit.test('when dispose is triggered should not throw error ', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.player.dispose();
this.clock.tick(45 * 1000);
assert.ok(!this.player.error(), 'should not throw player error when dispose is called.');
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);
});
// reset this.player because otherwise afterEach will fail
this.fixture.appendChild(this.video);
this.player = videojs(this.video);
});
QUnit.test('progress clears player timeout errors', function (assert) {
var errors$$1 = 0;
QUnit.test('progress clears player timeout errors', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
this.clock.tick(45 * 1000);
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');
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');
this.player.trigger('progress');
assert.strictEqual(this.player.error(), null, 'error removed');
});
this.player.trigger('progress');
assert.strictEqual(this.player.error(), null, 'error removed');
});
QUnit.test('reinitialising plugin during playback starts timeout handler', function (assert) {
var errors$$1 = 0;
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');
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// reinitialise while playing
this.player.errors();
// reinitialise while playing
this.player.errors();
this.clock.tick(45 * 1000);
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');
});
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');
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);
this.player.errors.timeout(1 * 1000);
assert.strictEqual(this.player.errors.timeout(), 1 * 1000, 'timeout was updated');
});
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;
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');
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// reinitialise while playing
this.player.errors.timeout(1000);
// reinitialise while playing
this.player.errors.timeout(1000);
this.clock.tick(1 * 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');
});
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
QUnit.test('stalling by itself is not an error', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.player.trigger('stalled');
// safari 7 on OSX can emit stalls when playback is just fine
QUnit.test('stalling by itself is not an error', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.player.trigger('stalled');
assert.ok(!this.player.error(), 'no error fired');
});
assert.ok(!this.player.error(), 'no error fired');
});
QUnit.test('timing out multiple times only throws a single error', function (assert) {
var errors$$1 = 0;
QUnit.test('timing out multiple times only throws a single error', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// trigger a player timeout
this.clock.tick(45 * 1000);
assert.strictEqual(errors$$1, 1, 'one error fired');
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// trigger a player timeout
this.clock.tick(45 * 1000);
assert.strictEqual(errors$$1, 1, 'one error fired');
// wait long enough for another timeout
this.clock.tick(50 * 1000);
assert.strictEqual(errors$$1, 1, 'only one error fired');
});
// wait long enough for another timeout
this.clock.tick(50 * 1000);
assert.strictEqual(errors$$1, 1, 'only one error fired');
});
QUnit.test('progress events while playing reset the player timeout', function (assert) {
var errors$$1 = 0;
QUnit.test('progress events while playing reset the player timeout', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// stalled for awhile
this.clock.tick(44 * 1000);
// but playback resumes!
this.player.trigger('progress');
this.clock.tick(44 * 1000);
this.player.on('error', function () {
errors$$1++;
});
this.player.src(sources);
this.player.trigger('play');
// stalled for awhile
this.clock.tick(44 * 1000);
// but playback resumes!
this.player.trigger('progress');
this.clock.tick(44 * 1000);
assert.strictEqual(errors$$1, 0, 'no errors emitted');
});
assert.strictEqual(errors$$1, 0, 'no errors emitted');
});
QUnit.test('no signs of playback triggers a player timeout', function (assert) {
var errors$$1 = 0;
QUnit.test('no signs of playback triggers a player timeout', function (assert) {
var errors$$1 = 0;
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
// swallow any timeupdate events
this.player.on('timeupdate', function (event) {
event.stopImmediatePropagation();
});
this.player.trigger('play');
this.clock.tick(45 * 1000);
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
// swallow any timeupdate events
this.player.on('timeupdate', function (event) {
event.stopImmediatePropagation();
});
this.player.trigger('play');
this.clock.tick(45 * 1000);
assert.strictEqual(errors$$1, 1, 'emitted a single error');
assert.strictEqual(this.player.error().code, -2, 'error code is -2');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_TIMEOUT', 'type is player timeout');
});
assert.strictEqual(errors$$1, 1, 'emitted a single error');
assert.strictEqual(this.player.error().code, -2, 'error code is -2');
assert.strictEqual(this.player.error().type, 'PLAYER_ERR_TIMEOUT', 'type is player timeout');
});
QUnit.test('time changes while playing reset the player timeout', function (assert) {
var errors$$1 = 0;
QUnit.test('time changes while playing reset the player timeout', function (assert) {
var errors$$1 = 0;
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.trigger('play');
this.clock.tick(44 * 1000);
this.player.currentTime = function () {
return 1;
};
this.player.trigger('timeupdate');
this.clock.tick(10 * 1000);
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.trigger('play');
this.clock.tick(44 * 1000);
this.player.currentTime = function () {
return 1;
};
this.player.trigger('timeupdate');
this.clock.tick(10 * 1000);
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
QUnit.test('time changes while playing ads reset the player timeout', function (assert) {
var errors$$1 = 0;
QUnit.test('time changes while playing ads reset the player timeout', function (assert) {
var errors$$1 = 0;
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.trigger('play');
this.clock.tick(44 * 1000);
this.player.currentTime = function () {
return 1;
};
this.player.trigger('adtimeupdate');
this.clock.tick(10 * 1000);
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.trigger('play');
this.clock.tick(44 * 1000);
this.player.currentTime = function () {
return 1;
};
this.player.trigger('adtimeupdate');
this.clock.tick(10 * 1000);
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
QUnit.test('time changes after a player timeout clears the error', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.clock.tick(45 * 1000);
this.player.currentTime = function () {
return 1;
};
this.player.trigger('timeupdate');
QUnit.test('time changes after a player timeout clears the error', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.clock.tick(45 * 1000);
this.player.currentTime = function () {
return 1;
};
this.player.trigger('timeupdate');
assert.ok(!this.player.error(), 'cleared the timeout');
});
assert.ok(!this.player.error(), 'cleared the timeout');
});
QUnit.test('player timeouts do not occur if the player is paused', function (assert) {
var errors$$1 = 0;
QUnit.test('player timeouts do not occur if the player is paused', function (assert) {
var errors$$1 = 0;
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.on('timeupdate', function (event) {
event.stopImmediatePropagation();
});
this.player.trigger('play');
// simulate a misbehaving player that doesn't fire `paused`
this.player.paused = function () {
return true;
};
this.clock.tick(45 * 1000);
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.on('timeupdate', function (event) {
event.stopImmediatePropagation();
});
this.player.trigger('play');
// simulate a misbehaving player that doesn't fire `paused`
this.player.paused = function () {
return true;
};
this.clock.tick(45 * 1000);
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
// video.paused is false at the end of a video on IE11, Win8 RT
QUnit.test('player timeouts do not occur if the video is ended', function (assert) {
var errors$$1 = 0;
// video.paused is false at the end of a video on IE11, Win8 RT
QUnit.test('player timeouts do not occur if the video is ended', function (assert) {
var errors$$1 = 0;
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.on('timeupdate', function (event) {
event.stopImmediatePropagation();
});
this.player.trigger('play');
// simulate a misbehaving player that doesn't fire `ended`
this.player.ended = function () {
return true;
};
this.clock.tick(45 * 1000);
this.player.src(sources);
this.player.on('error', function () {
errors$$1++;
});
this.player.on('timeupdate', function (event) {
event.stopImmediatePropagation();
});
this.player.trigger('play');
// simulate a misbehaving player that doesn't fire `ended`
this.player.ended = function () {
return true;
};
this.clock.tick(45 * 1000);
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
assert.strictEqual(errors$$1, 0, 'no error emitted');
});
QUnit.test('player timeouts do not overwrite existing errors', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.player.error({
type: 'custom',
code: -7
});
this.clock.tick(45 * 1000);
QUnit.test('player timeouts do not overwrite existing errors', function (assert) {
this.player.src(sources);
this.player.trigger('play');
this.player.error({
type: 'custom',
code: -7
});
this.clock.tick(45 * 1000);
assert.strictEqual(-7, this.player.error().code, 'error was not overwritten');
});
assert.strictEqual(-7, this.player.error().code, 'error was not overwritten');
});
QUnit.test('unrecognized error codes do not cause exceptions', function (assert) {
var errors$$1 = 0;
QUnit.test('unrecognized error codes do not cause exceptions', function (assert) {
var errors$$1 = 0;
this.player.on('error', function () {
errors$$1++;
});
this.player.error({
code: 'something-custom-that-no-one-could-have-predicted',
type: 'NOT_AN_ERROR_CONSTANT'
});
assert.ok(true, 'does not throw an exception');
assert.strictEqual(errors$$1, 1, 'emitted an error');
this.player.on('error', function () {
errors$$1++;
});
this.player.error({
code: 'something-custom-that-no-one-could-have-predicted',
type: 'NOT_AN_ERROR_CONSTANT'
});
assert.ok(true, 'does not throw an exception');
assert.strictEqual(errors$$1, 1, 'emitted an error');
// intentionally missing properties
this.player.error({});
assert.ok(true, 'does not throw an exception');
// intentionally missing properties
this.player.error({});
assert.ok(true, 'does not throw an exception');
assert.strictEqual(errors$$1, 2, 'emitted an error');
});
assert.strictEqual(errors$$1, 2, 'emitted an error');
});
QUnit.test('custom error details should override defaults', function (assert) {
var customError = { headline: 'test headline', message: 'test details' };
QUnit.test('custom error details should override defaults', function (assert) {
var customError = { headline: 'test headline', message: 'test details' };
// initialize the plugin with custom options
this.player.errors({ errors: { 4: customError } });
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.strictEqual(this.errorDisplay.$('.vjs-errors-headline').textContent, customError.headline, 'headline should match custom override value');
assert.strictEqual(this.errorDisplay.$('.vjs-errors-message').textContent, customError.message, 'message should match custom override value');
});
// initialize the plugin with custom options
this.player.errors({ errors: { 4: customError } });
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.strictEqual(this.errorDisplay.$('.vjs-errors-headline').textContent, customError.headline, 'headline should match custom override value');
assert.strictEqual(this.errorDisplay.$('.vjs-errors-message').textContent, customError.message, 'message should match custom override value');
});
QUnit.test('Append Flash error details when flash is not supported', function (assert) {
var Flash = videojs.getTech('Flash');
QUnit.test('Append Flash error details when flash is not supported', function (assert) {
var Flash = videojs.getTech('Flash');
// vjs6 won't have flash by default
if (!Flash) {
assert.notOk(Flash, 'flash tech not available, skipping unit test');
return;
}
// vjs6 won't have flash by default
if (!Flash) {
assert.notOk(Flash, 'flash tech not available, skipping unit test');
return;
}
var oldIsSupported = videojs.getComponent('Flash').isSupported;
var oldIsSupported = videojs.getComponent('Flash').isSupported;
// Mock up isSupported to be false
videojs.getComponent('Flash').isSupported = function () {
return false;
};
// Mock up isSupported to be false
videojs.getComponent('Flash').isSupported = function () {
return false;
};
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.equal(this.errorDisplay.$('.vjs-errors-flashmessage').textContent, 'If you are using an older browser please try upgrading or installing Flash.', 'Flash Error message should be displayed');
// Restoring isSupported to the old value
videojs.getComponent('Flash').isSupported = oldIsSupported;
});
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.equal(this.errorDisplay.$('.vjs-errors-flashmessage').textContent, 'If you are using an older browser please try upgrading or installing Flash.', 'Flash Error message should be displayed');
// Restoring isSupported to the old value
videojs.getComponent('Flash').isSupported = oldIsSupported;
});
QUnit.test('default error is dismissible', function (assert) {
// initialize the plugin
this.player.errors();
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(2);
// confirm results
assert.ok(this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(this.errorDisplay.$('.vjs-close-button'), 'close button is present');
});
QUnit.test('default error is dismissible', function (assert) {
// initialize the plugin
this.player.errors();
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(2);
// confirm results
assert.ok(this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(this.errorDisplay.$('.vjs-close-button'), 'close button is present');
});
QUnit.test('custom error is dismissible', function (assert) {
var customErrorDismiss = {
headline: 'test headline',
message: 'test details',
dismiss: true
};
QUnit.test('custom error is dismissible', function (assert) {
var customErrorDismiss = {
headline: 'test headline',
message: 'test details',
dismiss: true
};
// initialize the plugin with custom options
this.player.errors({ errors: { 4: customErrorDismiss } });
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.ok(this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(this.errorDisplay.$('.vjs-close-button'), 'close button is present');
});
// initialize the plugin with custom options
this.player.errors({ errors: { 4: customErrorDismiss } });
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.ok(this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is present');
assert.ok(this.errorDisplay.$('.vjs-close-button'), 'close button is present');
});
QUnit.test('custom error is not dismissible', function (assert) {
var customErrorNoDimiss = {
headline: 'test headline',
message: 'test details',
dismiss: false
};
QUnit.test('custom error is not dismissible', function (assert) {
var customErrorNoDimiss = {
headline: 'test headline',
message: 'test details',
dismiss: false
};
// initialize the plugin with custom options
this.player.errors({ errors: { 4: customErrorNoDimiss } });
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.ok(!this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is not present');
assert.ok(!this.errorDisplay.$('.vjs-close-button'), 'close button is not present');
});
// initialize the plugin with custom options
this.player.errors({ errors: { 4: customErrorNoDimiss } });
// tick forward enough to ready the player
this.clock.tick(1);
// trigger the error in question
this.player.error(4);
// confirm results
assert.ok(!this.errorDisplay.$('.vjs-errors-ok-button'), 'ok button is not present');
assert.ok(!this.errorDisplay.$('.vjs-close-button'), 'close button is not present');
});
QUnit.test('custom errors can be added at runtime', function (assert) {
this.player.errors();
QUnit.test('custom errors can be added at runtime', function (assert) {
this.player.errors();
// tick forward enough to ready the player
this.clock.tick(1);
// tick forward enough to ready the player
this.clock.tick(1);
var error = {
'-3': {
type: 'TEST',
headline: 'test',
message: 'test test'
}
};
var error = {
'-3': {
type: 'TEST',
headline: 'test',
message: 'test test'
}
};
this.player.errors.extend(error);
this.player.errors.extend(error);
this.player.error({ code: -3 });
this.player.error({ code: -3 });
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-headline').textContent, error['-3'].headline, 'headline should match custom override value');
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-headline').textContent, error['-3'].headline, 'headline should match custom override value');
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-message').textContent, error['-3'].message, 'message should match custom override value');
});
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-message').textContent, error['-3'].message, 'message should match custom override value');
});
QUnit.test('custom errors can be defined without a type at init time', function (assert) {
var error = {
TEST: {
headline: 'test',
message: 'test test'
}
};
QUnit.test('custom errors can be defined without a type at init time', function (assert) {
var error = {
TEST: {
headline: 'test',
message: 'test test'
}
};
this.player.errors({ errors: error });
this.player.errors({ errors: error });
// tick forward enough to ready the player
this.clock.tick(1);
// tick forward enough to ready the player
this.clock.tick(1);
this.player.error({ code: 'TEST' });
this.player.error({ code: 'TEST' });
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-headline').textContent, error.TEST.headline, 'headline should match custom override value');
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-headline').textContent, error.TEST.headline, 'headline should match custom override value');
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-message').textContent, error.TEST.message, 'message should match custom override value');
});
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-message').textContent, error.TEST.message, 'message should match custom override value');
});
QUnit.test('custom errors can be defined without a type at init time', function (assert) {
var error = {
TEST: {
headline: 'test',
message: 'test test'
}
};
QUnit.test('custom errors can be defined without a type at init time', function (assert) {
var error = {
TEST: {
headline: 'test',
message: 'test test'
}
};
this.player.errors();
this.player.errors();
// tick forward enough to ready the player
this.clock.tick(1);
// tick forward enough to ready the player
this.clock.tick(1);
this.player.errors.extend(error);
this.player.error({ code: 'TEST' });
this.player.errors.extend(error);
this.player.error({ code: 'TEST' });
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-headline').textContent, error.TEST.headline, 'headline should match custom override value');
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-headline').textContent, error.TEST.headline, 'headline should match custom override value');
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-message').textContent, error.TEST.message, 'message should match custom override value');
});
assert.strictEqual(this.player.errorDisplay.$('.vjs-errors-message').textContent, error.TEST.message, 'message should match custom override value');
});
QUnit.test('getAll()', function (assert) {
this.player.errors();
QUnit.test('getAll()', function (assert) {
this.player.errors();
var errors$$1 = this.player.errors.getAll();
var errors$$1 = this.player.errors.getAll();
assert.strictEqual(errors$$1['1'].type, 'MEDIA_ERR_ABORTED');
assert.strictEqual(errors$$1['2'].type, 'MEDIA_ERR_NETWORK');
assert.strictEqual(errors$$1['1'].type, 'MEDIA_ERR_ABORTED');
assert.strictEqual(errors$$1['2'].type, 'MEDIA_ERR_NETWORK');
this.player.errors.extend({
TEST: {
headline: 'test',
message: 'test test'
}
});
this.player.errors.extend({
TEST: {
headline: 'test',
message: 'test test'
}
});
errors$$1 = this.player.errors.getAll();
errors$$1 = this.player.errors.getAll();
assert.strictEqual(errors$$1['1'].type, 'MEDIA_ERR_ABORTED');
assert.strictEqual(errors$$1['2'].type, 'MEDIA_ERR_NETWORK');
assert.strictEqual(errors$$1.TEST.type, 'TEST');
});
assert.strictEqual(errors$$1['1'].type, 'MEDIA_ERR_ABORTED');
assert.strictEqual(errors$$1['2'].type, 'MEDIA_ERR_NETWORK');
assert.strictEqual(errors$$1.TEST.type, 'TEST');
});
}(QUnit,sinon,videojs));
}(videojs,QUnit,sinon));

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