videojs-errors
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -57,2 +57,4 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var FlashObj = _videoJs2['default'].getComponent('Flash'); | ||
// Default options for the plugin. | ||
@@ -221,8 +223,11 @@ var defaults = { | ||
} | ||
error = _videoJs2['default'].mergeOptions(error, options.errors[error.code || 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.code === 4 && !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>'; | ||
} | ||
display = player.getChild('errorDisplay'); | ||
@@ -619,3 +624,21 @@ // The code snippet below is to make sure we dispose any child closeButtons before | ||
_qunit2['default'].test('Append Flash error details when flash is not supported', function (assert) { | ||
var oldIsSupported = _videoJs2['default'].getComponent('Flash').isSupported; | ||
// Mock up isSupported to be false | ||
_videoJs2['default'].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(_globalDocument2['default'].querySelector('.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 | ||
_videoJs2['default'].getComponent('Flash').isSupported = oldIsSupported; | ||
}); | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"../src/plugin":4,"global/document":2}]},{},[5]); |
/** | ||
* videojs-errors | ||
* @version 1.0.5 | ||
* @version 1.1.0 | ||
* @copyright 2016 Brightcove | ||
@@ -63,2 +63,4 @@ * @license Apache-2.0 | ||
var FlashObj = _videoJs2['default'].getComponent('Flash'); | ||
// Default options for the plugin. | ||
@@ -227,8 +229,11 @@ var defaults = { | ||
} | ||
error = _videoJs2['default'].mergeOptions(error, options.errors[error.code || 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.code === 4 && !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>'; | ||
} | ||
display = player.getChild('errorDisplay'); | ||
@@ -235,0 +240,0 @@ // The code snippet below is to make sure we dispose any child closeButtons before |
/** | ||
* videojs-errors | ||
* @version 1.0.5 | ||
* @version 1.1.0 | ||
* @copyright 2016 Brightcove | ||
* @license Apache-2.0 | ||
*/ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,o.videojsErrors=e()}}(function(){return function e(o,n,t){function i(r,l){if(!n[r]){if(!o[r]){var s="function"==typeof require&&require;if(!l&&s)return s(r,!0);if(d)return d(r,!0);var a=new Error("Cannot find module '"+r+"'");throw a.code="MODULE_NOT_FOUND",a}var u=n[r]={exports:{}};o[r][0].call(u.exports,function(e){var n=o[r][1][e];return i(n?n:e)},u,u.exports,e,o,n,t)}return n[r].exports}for(var d="function"==typeof require&&require,r=0;r<t.length;r++)i(t[r]);return i}({1:[function(e,o,n){},{}],2:[function(e,o,n){(function(n){var t="undefined"!=typeof n?n:"undefined"!=typeof window?window:{},i=e("min-document");if("undefined"!=typeof document)o.exports=document;else{var d=t["__GLOBAL_DOCUMENT_CACHE@4"];d||(d=t["__GLOBAL_DOCUMENT_CACHE@4"]=i),o.exports=d}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"min-document":1}],3:[function(e,o,n){(function(e){"undefined"!=typeof window?o.exports=window:"undefined"!=typeof e?o.exports=e:"undefined"!=typeof self?o.exports=self:o.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,o,n){(function(t){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var d="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,r=i(d),l=e("global/window"),s=i(l),a=e("global/document"),u=i(a),f={header:"",code:"",message:"",timeout:45e3,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"}}},c=function(e,o){var n=void 0,t=function(){s["default"].clearTimeout(n),n=s["default"].setTimeout(function(){e.error()||e.paused()||e.ended()||e.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})},o.timeout),e.error()&&-2===e.error().code&&e.error(null)},i=[],d=function(){for(var o=void 0;i.length;)o=i.shift(),e.off(o[0],o[1]);s["default"].clearTimeout(n)},r=function(o,n){var t=function(){return e.paused()?d():e.ended()?d():void n.call(this)};e.on(o,t),i.push([o,t])};e.on("play",function(){var o=0;d(),t(),r(["timeupdate","adtimeupdate"],function(){var n=e.currentTime();n!==o&&(o=n,t())}),r("progress",t)}),e.on("dispose",function(){d()})},p=function(e,o){c(e,o),e.on("play",function(){e.currentSrc()||e.error({code:-1,type:"PLAYER_ERR_NO_SRC"})})},v=function(e,o){e.addClass("vjs-errors"),e.on("error",function(){var n=void 0,t="",i=e.error(),d=u["default"].createElement("div");if(i){i=r["default"].mergeOptions(i,o.errors[i.code||0]),i.message&&(t='<div class="vjs-errors-details">'+e.localize("Technical details")+'\n : <div class="vjs-errors-message">'+e.localize(i.message)+"</div>\n </div>"),n=e.getChild("errorDisplay"),n.getChild("closeButton")&&n.removeChild("closeButton"),n.closeable(!0),d.className="vjs-errors-dialog",d.id="vjs-errors-dialog",d.innerHTML='<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">'+this.localize(i.headline)+"</h2>\n <div><b>"+this.localize("Error Code")+"</b>: "+(i.type||i.code)+"</div>\n "+t+'\n </div>\n <div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">'+this.localize("OK")+"</button>\n </div>",n.fillWith(d),n.contentEl().firstChild.appendChild(n.getChild("closeButton").el()),(e.width()<=600||e.height()<=250)&&n.addClass("vjs-xs");var l=n.el().querySelector(".vjs-errors-ok-button");r["default"].on(l,"click",function(){n.close()})}}),p(e,o)},h=function(e){var o=this;this.ready(function(){v(o,r["default"].mergeOptions(f,e))})};r["default"].plugin("errors",h),n["default"]=h,o.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"global/document":2,"global/window":3}]},{},[4])(4)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;o="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,o.videojsErrors=e()}}(function(){return function e(o,n,t){function i(d,l){if(!n[d]){if(!o[d]){var s="function"==typeof require&&require;if(!l&&s)return s(d,!0);if(r)return r(d,!0);var a=new Error("Cannot find module '"+d+"'");throw a.code="MODULE_NOT_FOUND",a}var u=n[d]={exports:{}};o[d][0].call(u.exports,function(e){var n=o[d][1][e];return i(n?n:e)},u,u.exports,e,o,n,t)}return n[d].exports}for(var r="function"==typeof require&&require,d=0;d<t.length;d++)i(t[d]);return i}({1:[function(e,o,n){},{}],2:[function(e,o,n){(function(n){var t="undefined"!=typeof n?n:"undefined"!=typeof window?window:{},i=e("min-document");if("undefined"!=typeof document)o.exports=document;else{var r=t["__GLOBAL_DOCUMENT_CACHE@4"];r||(r=t["__GLOBAL_DOCUMENT_CACHE@4"]=i),o.exports=r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"min-document":1}],3:[function(e,o,n){(function(e){"undefined"!=typeof window?o.exports=window:"undefined"!=typeof e?o.exports=e:"undefined"!=typeof self?o.exports=self:o.exports={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,o,n){(function(t){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var r="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,d=i(r),l=e("global/window"),s=i(l),a=e("global/document"),u=i(a),f=d["default"].getComponent("Flash"),c={header:"",code:"",message:"",timeout:45e3,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"}}},p=function(e,o){var n=void 0,t=function(){s["default"].clearTimeout(n),n=s["default"].setTimeout(function(){e.error()||e.paused()||e.ended()||e.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})},o.timeout),e.error()&&-2===e.error().code&&e.error(null)},i=[],r=function(){for(var o=void 0;i.length;)o=i.shift(),e.off(o[0],o[1]);s["default"].clearTimeout(n)},d=function(o,n){var t=function(){return e.paused()?r():e.ended()?r():void n.call(this)};e.on(o,t),i.push([o,t])};e.on("play",function(){var o=0;r(),t(),d(["timeupdate","adtimeupdate"],function(){var n=e.currentTime();n!==o&&(o=n,t())}),d("progress",t)}),e.on("dispose",function(){r()})},v=function(e,o){p(e,o),e.on("play",function(){e.currentSrc()||e.error({code:-1,type:"PLAYER_ERR_NO_SRC"})})},h=function(e,o){e.addClass("vjs-errors"),e.on("error",function(){var n=void 0,t="",i=e.error(),r=u["default"].createElement("div");if(i){if(i=d["default"].mergeOptions(i,o.errors[i.code||0]),i.message&&(t='<div class="vjs-errors-details">'+e.localize("Technical details")+'\n : <div class="vjs-errors-message">'+e.localize(i.message)+"</div>\n </div>"),4===i.code&&!f.isSupported()){var l=e.localize(" * If you are using an older browser please try upgrading or installing Flash.");t+='<span class="vjs-errors-flashmessage">'+l+"</span>"}n=e.getChild("errorDisplay"),n.getChild("closeButton")&&n.removeChild("closeButton"),n.closeable(!0),r.className="vjs-errors-dialog",r.id="vjs-errors-dialog",r.innerHTML='<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">'+this.localize(i.headline)+"</h2>\n <div><b>"+this.localize("Error Code")+"</b>: "+(i.type||i.code)+"</div>\n "+t+'\n </div>\n <div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">'+this.localize("OK")+"</button>\n </div>",n.fillWith(r),n.contentEl().firstChild.appendChild(n.getChild("closeButton").el()),(e.width()<=600||e.height()<=250)&&n.addClass("vjs-xs");var s=n.el().querySelector(".vjs-errors-ok-button");d["default"].on(s,"click",function(){n.close()})}}),v(e,o)},y=function(e){var o=this;this.ready(function(){h(o,d["default"].mergeOptions(c,e))})};d["default"].plugin("errors",y),n["default"]=y,o.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"global/document":2,"global/window":3}]},{},[4])(4)}); |
@@ -21,2 +21,4 @@ 'use strict'; | ||
var FlashObj = _videoJs2['default'].getComponent('Flash'); | ||
// Default options for the plugin. | ||
@@ -185,8 +187,11 @@ var defaults = { | ||
} | ||
error = _videoJs2['default'].mergeOptions(error, options.errors[error.code || 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.code === 4 && !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>'; | ||
} | ||
display = player.getChild('errorDisplay'); | ||
@@ -193,0 +198,0 @@ // The code snippet below is to make sure we dispose any child closeButtons before |
{ | ||
"name": "videojs-errors", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"author": "Brightcove", | ||
@@ -5,0 +5,0 @@ "description": "A VideoJS plugin for custom error reporting", |
@@ -5,2 +5,4 @@ import videojs from 'video.js'; | ||
const FlashObj = videojs.getComponent('Flash'); | ||
// Default options for the plugin. | ||
@@ -171,5 +173,3 @@ const defaults = { | ||
} | ||
error = videojs.mergeOptions(error, options.errors[error.code || 0]); | ||
if (error.message) { | ||
@@ -180,2 +180,8 @@ details = `<div class="vjs-errors-details">${player.localize('Technical details')} | ||
} | ||
if (error.code === 4 && !FlashObj.isSupported()) { | ||
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>`; | ||
} | ||
display = player.getChild('errorDisplay'); | ||
@@ -182,0 +188,0 @@ // The code snippet below is to make sure we dispose any child closeButtons before |
@@ -340,1 +340,19 @@ import document from 'global/document'; | ||
}); | ||
QUnit.test('Append Flash error details when flash is not supported', function(assert) { | ||
let oldIsSupported = videojs.getComponent('Flash').isSupported; | ||
// Mock up isSupported to be false | ||
videojs.getComponent('Flash').isSupported = () => 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(document.querySelector('.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; | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93560
1759