Files
videojs-player/js/videojs-errors.min.js

2 lines
6.1 KiB
JavaScript

/*! @name videojs-errors @version 6.0.0 @license Apache-2.0 */
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("video.js")):"function"==typeof define&&define.amd?define(["video.js"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).videojsErrors=o(e.videojs)}(this,(function(e){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=o(e),i="6.0.0";const n=t.default.getComponent("Flash"),r=!t.default.browser.IS_IPHONE,s=t.default.registerPlugin||t.default.plugin,d={header:"",code:"",message:"",timeout:45e3,backgroundTimeout:3e5,dismiss:r,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:"It looks like you're having playback issues. Reloading the video may help."},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."}}},a=function(e,o){let r,s,l;const c=[],u=function(e){o.errors=t.default.mergeOptions(o.errors,e),Object.keys(o.errors).forEach((e=>{const t=o.errors[e];t.type||(t.type=e)}))};u();const f=function(){e.error()&&-2===e.error().code&&e.error(null),e.clearTimeout(s),e.clearTimeout(r),l&&(l=!1,e.removeClass("vjs-waiting"));const t=[1/0,-1],i=(e,o)=>-1!==e.indexOf(o);"hidden"===document.visibilityState&&(e.muted()||i(t,o.backgroundTimeout))||"visible"===document.visibilityState&&i(t,o.timeout)||(s=e.setTimeout((function(){e.error()||e.paused()||e.ended()||(l=!0,e.addClass("vjs-waiting"))}),1e3),r=e.setTimeout((function(){e.error()||e.paused()||e.ended()||e.error({code:-2,type:"PLAYER_ERR_TIMEOUT"})}),"hidden"===document.visibilityState?o.backgroundTimeout:o.timeout))},h=function(){let o;for(;c.length;)o=c.shift(),e.off(o[0],o[1]);e.clearTimeout(r),e.clearTimeout(s)},p=function(){let o=0;h(),f(),function(o,t){const i=function(){if(!e.error()){const o=e.$(".vjs-tech");if(o&&"application/x-shockwave-flash"===o.type&&!o.vjs_getProperty)return void e.error({code:-2,type:"PLAYER_ERR_TIMEOUT"});if(e.paused())return f();if(e.ended())return f()}t.call(this)};e.on(o,i),c.push([o,i])}(["timeupdate","adtimeupdate"],(function(){const t=e.currentTime();t!==o&&(o=t,f())})),e.off(document,"visibilitychange",p),e.on(document,"visibilitychange",p)},m=function(){e.currentSrc()||e.error({code:-1,type:"PLAYER_ERR_NO_SRC"})},v=function(){let i="",r=e.error();const s=document.createElement("div");let d="";if(!r)return;if(e.off(document,"visibilitychange",p),r=t.default.mergeOptions(r,o.errors[r.code||r.type||0]),r.message&&(i=`<div class="vjs-errors-details">${e.localize("Technical details")}\n : <div class="vjs-errors-message">${e.localize(r.message)}</div>\n </div>`),4===r.code&&n&&!n.isSupported()){i+=`<span class="vjs-errors-flashmessage">${e.localize("If you are using an older browser please try upgrading or installing Flash.")}</span>`}const a=e.getChild("errorDisplay");s.className="vjs-errors-dialog";const l=`<div class="vjs-errors-code"><b>${this.localize("Error Code")}:</b> ${r.type||r.code}</div>`,c=-2===r.code;d=`<div class="vjs-errors-content-container">\n <h2 class="vjs-errors-headline">${this.localize(r.headline)}</h2>\n ${c?"":l}\n ${c?"":i}\n </div>`;const u=a.closeable(!("dismiss"in r)||r.dismiss);if(c){d+=`<div class="vjs-errors-timeout-button-container">\n <button>${this.localize("Reload Video")}</button>\n <button>${this.localize("Dismiss")}</button>\n </div>`,s.innerHTML=d,a.fillWith(s),a.getChild("closeButton").hide();const o=a.el().querySelector(".vjs-errors-timeout-button-container > button:first-child"),t=a.el().querySelector(".vjs-errors-timeout-button-container > button:last-child");e.on(o,"click",(function(){const o=e.currentSource();e.reset(),e.src(o)})),e.on(t,"click",(function(){a.close()})),a.one("modalclose",(()=>{e.off(o),e.off(t)}))}else if(u){d+=`<div class="vjs-errors-ok-button-container">\n <button class="vjs-errors-ok-button">${this.localize("OK")}</button>\n </div>`,s.innerHTML=d,a.fillWith(s),a.contentEl().firstChild.appendChild(a.getChild("closeButton").el());const o=a.el().querySelector(".vjs-errors-ok-button");e.on(o,"click",(function(){a.close()}))}else s.innerHTML=d,a.fillWith(s);(e.currentWidth()<=600||e.currentHeight()<=250)&&a.addClass("vjs-xs"),a.one("modalclose",(()=>e.error(null)))},y=function(){h(),e.removeClass("vjs-errors"),e.off("play",p),e.off(document,"visibilitychange",p),e.off("play",m),e.off("dispose",y),e.off(["aderror","error"],v)},R=function(o){y(),a(e,t.default.mergeOptions(d,o))};R.extend=e=>u(e),R.getAll=()=>t.default.mergeOptions(o.errors),R.timeout=function(t){if(void 0===t)return o.timeout;t!==o.timeout&&(o.timeout=t,e.paused()||p())},R.backgroundTimeout=function(t){if(void 0===t)return o.backgroundTimeout;t!==o.backgroundTimeout&&(o.backgroundTimeout=t,e.paused()||p())},R.disableProgress=()=>{},e.on("play",p),e.on("play",m),e.on("dispose",y),e.on(["aderror","contenterror","error"],v),e.ready((()=>{e.addClass("vjs-errors")})),e.paused()||p(),R.VERSION=i,e.errors=R},l=function(e){a(this,t.default.mergeOptions(d,e))};return["extend","getAll"].forEach((e=>{l[e]=function(){t.default.log.warn(`The errors.${e}() method is not available until the plugin has been initialized!`)}})),l.VERSION=i,s("errors",l),l}));