Created
June 3, 2017 12:25
-
-
Save nikitug/869c73cfa9fc08f2ea633b0b06d8f7ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=r(1),i=n(o),s=r(2),a=n(s),u=r(21),c=r(22),f=n(c),d=r(23),l=n(d),y=void 0,h=!1,p=function(){function e(t,r,n){(0,i["default"])(this,e),n=n||r.options_,t.src&&(this.el_=r.el(),this.player_=videojs(n.playerId),this.protection_=t&&t.protection,this.tech_=r,this.onCertificateError=this.onCertificateError.bind(this),this.onCertificateLoad=this.onCertificateLoad.bind(this),this.onKeySessionWebkitKeyAdded=this.onKeySessionWebkitKeyAdded.bind(this),this.onKeySessionWebkitKeyError=this.onKeySessionWebkitKeyError.bind(this),this.onKeySessionWebkitKeyMessage=this.onKeySessionWebkitKeyMessage.bind(this),this.onLicenseError=this.onLicenseError.bind(this),this.onLicenseLoad=this.onLicenseLoad.bind(this),this.onVideoError=this.onVideoError.bind(this),this.onVideoWebkitNeedKey=this.onVideoWebkitNeedKey.bind(this),r.isReady_=!1,this.src(t),r.triggerReady())}return(0,a["default"])(e,null,[{key:"setLogToBrowserConsole",value:function(){var e=!(arguments.length<=0||void 0===arguments[0])&&arguments[0];h=e}}]),(0,a["default"])(e,[{key:"createKeySession",value:function(e,t){if(this.log("createKeySession()"),!this.el_.webkitKeys){if(!WebKitMediaKeys.isTypeSupported(e,"video/mp4"))throw new Error("Key System not supported");this.el_.webkitSetMediaKeys(new WebKitMediaKeys(e))}if(!this.el_.webkitKeys)throw new Error("Could not create MediaKeys");var r=this.el_.webkitKeys.createSession("video/mp4",t);if(!r)throw new Error("Could not create key session");return r}},{key:"fetchCertificate",value:function(e){var t=this,r=e.callback;this.log("fetchCertificate()");var n=this.protection_.certificateUrl,o=new XMLHttpRequest;o.responseType="arraybuffer",o.addEventListener("error",this.onCertificateError,!1),o.addEventListener("load",function(e){t.onCertificateLoad(e,{callback:r})},!1),o.open("GET",n,!0),o.send()}},{key:"fetchLicense",value:function(e){var t=e.target,r=e.message;this.log("fetchLicense()");var n=this.protection_.licenseUrl,o=new XMLHttpRequest;o.responseType="arraybuffer",o.session=t,o.addEventListener("error",this.onLicenseError,!1),o.addEventListener("load",this.onLicenseLoad,!1),o.open("POST",n,!0),o.setRequestHeader("Content-type","application/octet-stream"),o.send(r)}},{key:"getErrorResponse",value:function(e){return e?String.fromCharCode.apply(null,new Uint8Array(e)):"NONE"}},{key:"hasProtection",value:function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.certificateUrl,r=e.keySystem,n=e.licenseUrl;return this.log("hasProtection()"),t&&r&&n}},{key:"log",value:function(){var e;h&&(e=console).log.apply(e,arguments)}},{key:"onCertificateError",value:function(){this.log("onCertificateError()"),this.player_.error({code:0,message:"Failed to retrieve the server certificate."})}},{key:"onCertificateLoad",value:function(e,t){var r=t.callback;this.log("onCertificateLoad()");var n=e.target,o=n.response,i=n.status;return 200!==i?void this.onRequestError(e.target,l["default"].FETCH_CERTIFICATE):(y=new Uint8Array(o),void r())}},{key:"onRequestError",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?l["default"].UNKNOWN:arguments[1];this.log("onRequestError()");var r=t+" - DRM: com.apple.fps.1_0 update, \n XHR status is '"+e.statusText+"("+e.status+")', expected to be 200. \n readyState is '"+e.readyState+"'. \n Response is "+this.getErrorResponse(e.response);this.player_.error({code:0,message:r})}},{key:"onKeySessionWebkitKeyAdded",value:function(){this.log("onKeySessionWebkitKeyAdded()"),this.log("Decryption key was added to the session.")}},{key:"onKeySessionWebkitKeyError",value:function(){this.log("onKeySessionWebkitKeyError()"),this.player_.error({code:0,message:"A decryption key error was encountered."})}},{key:"onKeySessionWebkitKeyMessage",value:function(e){this.log("onKeySessionWebkitKeyMessage()");var t=e.message,r=e.target;this.fetchLicense({message:t,target:r})}},{key:"onLicenseError",value:function(){this.log("onLicenseError()"),this.player_.error({code:0,message:"The license request failed."})}},{key:"onLicenseLoad",value:function(e){this.log("onLicenseLoad()");var t=e.target,r=t.response,n=t.session,o=t.status;return 200!==o?void this.onRequestError(e.target,l["default"].FETCH_LICENCE):void n.update(new Uint8Array(r))}},{key:"onVideoError",value:function(){this.log("onVideoError()"),this.player_.error({code:0,message:"A video playback error occurred."})}},{key:"onVideoWebkitNeedKey",value:function(e){this.log("onVideoWebkitNeedKey()");var t=this.protection_.keySystem,r=(0,u.getHostnameFromURI)((0,u.arrayToString)(e.initData)),n=(0,f["default"])(e.initData,r,y),o=this.createKeySession(t,n);o.contentId=r,o.addEventListener("webkitkeyadded",this.onKeySessionWebkitKeyAdded,!1),o.addEventListener("webkitkeyerror",this.onKeySessionWebkitKeyError,!1),o.addEventListener("webkitkeymessage",this.onKeySessionWebkitKeyMessage,!1)}},{key:"src",value:function(e){var t=this,r=e.src;return this.hasProtection(this.protection_)?(this.el_.addEventListener("webkitneedkey",this.onVideoWebkitNeedKey,!1),y?void this.tech_.src(r):void this.fetchCertificate({callback:function(){t.tech_.src(r)}})):void this.tech_.src(r)}}]),e}();videojs.fairplaySourceHandler=function(){return{canHandleSource:function(e){if(!window.WebKitMediaKeys)return"";var t=e&&e.protection&&e.protection.keySystem,r=WebKitMediaKeys.isTypeSupported(t,"video/mp4");return r?"probably":""},handleSource:function(e,t,r){return new p(e,t,r)},canPlayType:function(e){return videojs.fairplaySourceHandler.canPlayType(e)}}},videojs.fairplaySourceHandler.canPlayType=function(e){var t=/application\/x-mpegURL/i;return t.test(e)?"maybe":""},window.MediaSource&&videojs.getComponent("Html5").registerSourceHandler(videojs.fairplaySourceHandler(),0),videojs.Html5Fairplay=p,t["default"]=p},function(e,t){"use strict";t.__esModule=!0,t["default"]=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=r(3),i=n(o);t["default"]=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),(0,i["default"])(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}()},function(e,t,r){e.exports={"default":r(4),__esModule:!0}},function(e,t,r){r(5);var n=r(8).Object;e.exports=function(e,t,r){return n.defineProperty(e,t,r)}},function(e,t,r){var n=r(6);n(n.S+n.F*!r(16),"Object",{defineProperty:r(12).f})},function(e,t,r){var n=r(7),o=r(8),i=r(9),s=r(11),a="prototype",u=function(e,t,r){var c,f,d,l=e&u.F,y=e&u.G,h=e&u.S,p=e&u.P,v=e&u.B,b=e&u.W,g=y?o:o[t]||(o[t]={}),E=g[a],k=y?n:h?n[t]:(n[t]||{})[a];y&&(r=t);for(c in r)f=!l&&k&&void 0!==k[c],f&&c in g||(d=f?k[c]:r[c],g[c]=y&&"function"!=typeof k[c]?r[c]:v&&f?i(d,n):b&&k[c]==d?function(e){var t=function(t,r,n){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,r)}return new e(t,r,n)}return e.apply(this,arguments)};return t[a]=e[a],t}(d):p&&"function"==typeof d?i(Function.call,d):d,p&&((g.virtual||(g.virtual={}))[c]=d,e&u.R&&E&&!E[c]&&s(E,c,d)))};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,e.exports=u},function(e,t){var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t){var r=e.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(e,t,r){var n=r(10);e.exports=function(e,t,r){if(n(e),void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,o){return e.call(t,r,n,o)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,r){var n=r(12),o=r(20);e.exports=r(16)?function(e,t,r){return n.f(e,t,o(1,r))}:function(e,t,r){return e[t]=r,e}},function(e,t,r){var n=r(13),o=r(15),i=r(19),s=Object.defineProperty;t.f=r(16)?Object.defineProperty:function(e,t,r){if(n(e),t=i(t,!0),n(r),o)try{return s(e,t,r)}catch(a){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e}},function(e,t,r){var n=r(14);e.exports=function(e){if(!n(e))throw TypeError(e+" is not an object!");return e}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,r){e.exports=!r(16)&&!r(17)(function(){return 7!=Object.defineProperty(r(18)("div"),"a",{get:function(){return 7}}).a})},function(e,t,r){e.exports=!r(17)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t){e.exports=function(e){try{return!!e()}catch(t){return!0}}},function(e,t,r){var n=r(14),o=r(7).document,i=n(o)&&n(o.createElement);e.exports=function(e){return i?o.createElement(e):{}}},function(e,t,r){var n=r(14);e.exports=function(e,t){if(!n(e))return e;var r,o;if(t&&"function"==typeof(r=e.toString)&&!n(o=r.call(e)))return o;if("function"==typeof(r=e.valueOf)&&!n(o=r.call(e)))return o;if(!t&&"function"==typeof(r=e.toString)&&!n(o=r.call(e)))return o;throw TypeError("Can't convert object to primitive value")}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){"use strict";function r(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))}function n(e){for(var t=atob(e),r=t.length,n=new Uint8Array(new ArrayBuffer(r)),o=0;o<r;o++)n[o]=t.charCodeAt(o);return n}function o(e){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=void 0,n=void 0,o=void 0,i=void 0,s=void 0,a=void 0,u=void 0,c=0,f="";c<e.length;)r=e[c++],n=c<e.length?e[c++]:Number.NaN,o=c<e.length?e[c++]:Number.NaN,i=r>>2,s=(3&r)<<4|n>>4,a=(15&n)<<2|o>>6,u=63&o,isNaN(n)?a=u=64:isNaN(o)&&(u=64),f+=t.charAt(i)+t.charAt(s)+t.charAt(a)+t.charAt(u);return f}function i(e){var t=document.createElement("a");return t.href=e,t.hostname}function s(e){for(var t=e.length,r=new ArrayBuffer(2*t),n=new Uint16Array(r),o=0;o<t;o++)n[o]=e.charCodeAt(o);return n}Object.defineProperty(t,"__esModule",{value:!0}),t.arrayToString=r,t.base64DecodeUint8Array=n,t.base64EncodeUint8Array=o,t.getHostnameFromURI=i,t.stringToArray=s},function(e,t,r){"use strict";function n(e,t,r){"string"==typeof t&&(t=(0,o.stringToArray)(t));var n=e.byteLength+4+t.byteLength+4+r.byteLength,i=0,s=new ArrayBuffer(n),a=new DataView(s),u=new Uint8Array(s,i,e.byteLength);u.set(e),i+=u.byteLength,a.setUint32(i,t.byteLength,!0),i+=4;var c=new Uint16Array(s,i,t.length);c.set(t),i+=c.byteLength,a.setUint32(i,r.byteLength,!0),i+=4;var f=new Uint8Array(s,i,r.byteLength);return f.set(r),new Uint8Array(s,0,s.byteLength)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n;var o=r(21)},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]={FETCH_CERTIFICATE:"FETCH CERTIFICATE",FETCH_LICENCE:"FETCH LICENCE",UNKNOWN:"UNKNOWN"}}])}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment