videojs-errors
Version:
A VideoJS plugin for custom error reporting
7 lines • 5.42 kB
JavaScript
/**
* videojs-errors
* @version 1.1.2
* @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 r(d,l){if(!n[d]){if(!o[d]){var s="function"==typeof require&&require;if(!l&&s)return s(d,!0);if(i)return i(d,!0);var a=new Error("Cannot find module '"+d+"'");throw a.code="MODULE_NOT_FOUND",a}var f=n[d]={exports:{}};o[d][0].call(f.exports,function(e){var n=o[d][1][e];return r(n?n:e)},f,f.exports,e,o,n,t)}return n[d].exports}for(var i="function"==typeof require&&require,d=0;d<t.length;d++)r(t[d]);return r}({1:[function(e,o,n){},{}],2:[function(e,o,n){(function(n){var t="undefined"!=typeof n?n:"undefined"!=typeof window?window:{},r=e("min-document");if("undefined"!=typeof document)o.exports=document;else{var i=t["__GLOBAL_DOCUMENT_CACHE@4"];i||(i=t["__GLOBAL_DOCUMENT_CACHE@4"]=r),o.exports=i}}).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 r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var i="undefined"!=typeof window?window.videojs:"undefined"!=typeof t?t.videojs:null,d=r(i),l=e("global/window"),s=r(l),a=e("global/document"),f=r(a),u=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,n){var t=void 0,r=[],i=function(){s.default.clearTimeout(t),t=s.default.setTimeout(function(){o.error()||o.paused()||o.ended()||o.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})},n.timeout),o.error()&&o.error().code===-2&&o.error(null)},l=function(){for(var e=void 0;r.length;)e=r.shift(),o.off(e[0],e[1]);s.default.clearTimeout(t)},a=function(e,n){var t=function(){if(!o.error()){var e=o.$(".vjs-tech");if(e&&"application/x-shockwave-flash"===e.type&&!e.vjs_getProperty)return void o.error({code:-2,type:"PLAYER_ERR_TIMEOUT"});if(o.paused())return i();if(o.ended())return i()}n.call(this)};o.on(e,t),r.push([e,t])},p=function(){var e=0;l(),i(),a(["timeupdate","adtimeupdate"],function(){var n=o.currentTime();n!==e&&(e=n,i())}),a("progress",i)},v=function(){o.currentSrc()||o.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},h=function(){var e=void 0,t="",r=o.error(),i=f.default.createElement("div");if(r){if(r=d.default.mergeOptions(r,n.errors[r.code||0]),r.message&&(t='<div class="vjs-errors-details">'+o.localize("Technical details")+'\n : <div class="vjs-errors-message">'+o.localize(r.message)+"</div>\n </div>"),4===r.code&&!u.isSupported()){var l=o.localize(" * If you are using an older browser please try upgrading or installing Flash.");t+='<span class="vjs-errors-flashmessage">'+l+"</span>"}e=o.getChild("errorDisplay"),e.getChild("closeButton")&&e.removeChild("closeButton"),e.closeable(!0),i.className="vjs-errors-dialog",i.id="vjs-errors-dialog",i.innerHTML='<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">'+this.localize(r.headline)+"</h2>\n <div><b>"+this.localize("Error Code")+"</b>: "+(r.type||r.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>",e.fillWith(i),e.contentEl().firstChild.appendChild(e.getChild("closeButton").el()),(o.width()<=600||o.height()<=250)&&e.addClass("vjs-xs");var s=e.el().querySelector(".vjs-errors-ok-button");d.default.on(s,"click",function(){e.close()})}},y=function e(){l(),o.removeClass("vjs-errors"),o.off("play",p),o.off("play",v),o.off("dispose",e),o.off("error",h)},w=function(n){y(),e(o,d.default.mergeOptions(c,n))};o.on("play",p),o.on("play",v),o.on("dispose",y),o.on("error",h),o.ready(function(){o.addClass("vjs-errors")}),o.errors=w},v=function(e){p(this,d.default.mergeOptions(c,e))};d.default.plugin("errors",v),n.default=v,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)});