UNPKG

shaka-player

Version:
114 lines (110 loc) 85.1 kB
(function(){var g={}; (function(window){var k,aa=this;aa.Eb=!0;function m(a,b){var c=a.split("."),d=aa;c[0]in d||!d.execScript||d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)c.length||void 0===b?d[e]?d=d[e]:d=d[e]={}:d[e]=b}function ba(a){var b=ca;function c(){}c.prototype=b.prototype;a.Ib=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.Fb=function(a,c,f){return b.prototype[c].apply(a,Array.prototype.slice.call(arguments,2))}};/* Copyright 2016 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ function da(a){this.c=Math.exp(Math.log(.5)/a);this.a=this.b=0}function ea(a,b,c){var d=Math.pow(a.c,b);a.b=c*(1-d)+d*a.b;a.a+=b}function fa(a){return a.b/(1-Math.pow(a.c,a.a))};function ga(){this.a=new da(3);this.c=new da(10);this.b=5E5}function ha(a){return.5>a.a.a?a.b:Math.min(fa(a.a),fa(a.c))};function ia(){this.h=null;this.c=!1;this.b=new ga;this.g={};this.a={};this.i=!1;this.f=null}k=ia.prototype;k.stop=function(){this.h=null;this.c=!1;this.g={};this.a={};this.f=null};k.init=function(a){this.h=a};k.chooseStreams=function(a){this.g=a;this.a={};return ja(this)};k.enable=function(){this.c=!0};k.disable=function(){this.c=!1}; k.segmentDownloaded=function(a,b,c){var d=this.b;a=b-a;65536>c||(a=Math.max(a,50),c=8E3*c/a,a/=1E3,ea(d.a,a,c),ea(d.c,a,c));if(null!=this.f&&this.c)a:{d=Date.now()-this.f;if(!this.i){if(4E3>d)break a;this.i=!0}else if(8E3>d)break a;d=this.a.audio;c=this.a.video;a=ja(this);a.audio==d&&a.video==c||this.h(a)}};k.getBandwidthEstimate=function(){return ha(this.b)};k.setDefaultEstimate=function(a){this.b.b=a}; function ja(a){var b={},c;(c=a.g.audio)?(c=ka(c),c=c[Math.floor(c.length/2)]):c=null;c&&(b.audio=c,a.a.audio=c);if(c=a.g.video){c=ka(c);for(var d=a.a.audio,d=d&&d.bandwidth||0,e=ha(a.b),f=c[0],g=0;g<c.length;++g){var h=c[g],l=g+1<c.length?c[g+1]:{bandwidth:Number.POSITIVE_INFINITY};h.bandwidth&&(l=(l.bandwidth+d)/.85,e>=(h.bandwidth+d)/.95&&e<=l&&(f=h))}c=f}else c=null;c&&(b.video=c,a.a.video=c);a.f=Date.now();return b} function ka(a){return a.streams.slice(0).sort(function(a,c){return a.bandwidth-c.bandwidth})};var la={},ma={};m("shaka.media.ManifestParser.registerParserByExtension",function(a,b){ma[a]=b});m("shaka.media.ManifestParser.registerParserByMime",function(a,b){la[a]=b});function na(){var a={basic:!0},b;for(b in la)a[b]=!0;for(b in ma)a[b]=!0;["application/dash+xml","application/x-mpegurl","application/vnd.apple.mpegurl","application/vnd.ms-sstr+xml"].forEach(function(b){a[b]=!!la[b]});["mpd","m3u8","ism"].forEach(function(b){a[b]=!!ma[b]});return a};function oa(a,b,c,d,e){this.a=a;this.c=b;this.b=c;this.g=d;this.f=e}m("shaka.media.PresentationTimeline",oa);function p(a){return null==a.c||a.b==Number.POSITIVE_INFINITY?0:Math.max(0,pa(a)-a.b)}function pa(a){return null==a.c?a.a:Math.min(Math.max(0,(Date.now()+a.f)/1E3-a.g-a.c),a.a)};function qa(a,b,c){this.uris=a;this.c=b;this.b=c}m("shaka.media.InitSegmentReference",qa);function v(a,b,c,d,e,f){this.position=a;this.startTime=b;this.a=c;this.uris=d;this.c=e;this.b=f}m("shaka.media.SegmentReference",v);function ra(a,b){if(!a)return 0;for(var c=0;c<a.length;++c)if(b+1E-4>=a.start(c)&&b<a.end(c))return a.end(c)-b;return 0};m("shaka.polyfill.installAll",function(){for(var a=0;a<sa.length;++a)sa[a]()});var sa=[];function ta(a){sa.push(a)}m("shaka.polyfill.register",ta);function ua(a){var b=a.type.replace(/^(webkit|moz|MS)/,"").toLowerCase(),b=new Event(b,a);a.target.dispatchEvent(b)} ta(function(){if(window.Document){var a=Element.prototype;a.requestFullscreen=a.requestFullscreen||a.mozRequestFullScreen||a.msRequestFullscreen||a.webkitRequestFullscreen;a=Document.prototype;a.exitFullscreen=a.exitFullscreen||a.mozCancelFullScreen||a.msExitFullscreen||a.webkitExitFullscreen;"fullscreenElement"in document||Object.defineProperty(document,"fullscreenElement",{get:function(){return document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement}});document.addEventListener("webkitfullscreenchange", ua);document.addEventListener("webkitfullscreenerror",ua);document.addEventListener("mozfullscreenchange",ua);document.addEventListener("mozfullscreenerror",ua);document.addEventListener("MSFullscreenChange",ua);document.addEventListener("MSFullscreenError",ua)}});function va(){return Promise.reject(Error("The key system specified is not supported."))}function wa(a){return null==a?Promise.resolve():Promise.reject(Error("MediaKeys not supported."))}function xa(){throw new TypeError("Illegal constructor.");}xa.prototype.createSession=function(){};xa.prototype.setServerCertificate=function(){};function za(){throw new TypeError("Illegal constructor.");}za.prototype.getConfiguration=function(){};za.prototype.createMediaKeys=function(){};function w(a){this.c=[];this.b=[];this.Y=Aa;if(a)try{a(this.N.bind(this),this.a.bind(this))}catch(b){this.a(b)}}var Aa=0;function Ba(a){var b=new w;b.N(a);return b}function Ca(a){var b=new w;b.a(a);return b}function Da(a){function b(a,b,c){a.Y==Aa&&(e[b]=c,d++,d==e.length&&a.N(e))}var c=new w;if(!a.length)return c.N([]),c;for(var d=0,e=Array(a.length),f=c.a.bind(c),g=0;g<a.length;++g)a[g]&&a[g].then?a[g].then(b.bind(null,c,g),f):b(c,g,a[g]);return c} function Ea(a){for(var b=new w,c=b.N.bind(b),d=b.a.bind(b),e=0;e<a.length;++e)a[e]&&a[e].then?a[e].then(c,d):c(a[e]);return b}w.prototype.then=function(a,b){var c=new w;switch(this.Y){case 1:Fa(this,c,a);break;case 2:Fa(this,c,b);break;case Aa:this.c.push({C:c,ua:a}),this.b.push({C:c,ua:b})}return c};w.prototype.then=w.prototype.then;w.prototype["catch"]=function(a){return this.then(void 0,a)};w.prototype["catch"]=w.prototype["catch"]; w.prototype.N=function(a){if(this.Y==Aa){this.sa=a;this.Y=1;for(a=0;a<this.c.length;++a)Fa(this,this.c[a].C,this.c[a].ua);this.c=[];this.b=[]}};w.prototype.a=function(a){if(this.Y==Aa){this.sa=a;this.Y=2;for(a=0;a<this.b.length;++a)Fa(this,this.b[a].C,this.b[a].ua);this.c=[];this.b=[]}}; function Fa(a,b,c){Ga.push(function(){if(c&&"function"==typeof c){try{var a=c(this.sa)}catch(f){b.a(f);return}var e;try{e=a&&a.then}catch(f){b.a(f);return}a instanceof w?a==b?b.a(new TypeError("Chaining cycle detected")):a.then(b.N.bind(b),b.a.bind(b)):e?Ha(a,e,b):b.N(a)}else 1==this.Y?b.N(this.sa):b.a(this.sa)}.bind(a));null==Ia&&(Ia=Ja(Ka))} function Ha(a,b,c){try{var d=!1;b.call(a,function(a){if(!d){d=!0;var b;try{b=a&&a.then}catch(g){c.a(g);return}b?Ha(a,b,c):c.N(a)}},c.a.bind(c))}catch(e){c.a(e)}}function Ka(){for(;Ga.length;){null!=Ia&&(La(Ia),Ia=null);var a=Ga;Ga=[];for(var b=0;b<a.length;++b)a[b]()}}function Ja(){return 0}function La(){}var Ia=null,Ga=[]; ta(function(){window.Promise||(window.Promise=w,window.Promise.resolve=Ba,window.Promise.reject=Ca,window.Promise.all=Da,window.Promise.race=Ea,window.setImmediate?(Ja=function(a){return window.setImmediate(a)},La=function(a){return window.clearImmediate(a)}):(Ja=function(a){return window.setTimeout(a,0)},La=function(a){return window.clearTimeout(a)}))});function Ma(){return{droppedVideoFrames:this.webkitDroppedFrameCount,totalVideoFrames:this.webkitDecodedFrameCount,corruptedVideoFrames:0,creationTime:NaN,totalFrameDelay:0}}ta(function(){if(window.HTMLVideoElement){var a=HTMLVideoElement.prototype;!a.getVideoPlaybackQuality&&"webkitDroppedFrameCount"in a&&(a.getVideoPlaybackQuality=Ma)}});function Na(a,b,c){for(var d=0;d<a.length;++d)if(c(a[d],b))return d;return-1};function x(a,b,c){this.category=a;this.code=b;this.data=Array.prototype.slice.call(arguments,2)}m("shaka.util.Error",x);x.prototype.toString=function(){return"shaka.util.Error "+JSON.stringify(this,null," ")};x.Category={NETWORK:1,TEXT:2,MEDIA:3,MANIFEST:4,STREAMING:5,DRM:6}; x.Code={UNSUPPORTED_SCHEME:1E3,BAD_HTTP_STATUS:1001,HTTP_ERROR:1002,TIMEOUT:1003,MALFORMED_DATA_URI:1004,UNKNOWN_DATA_URI_ENCODING:1005,INVALID_TEXT_HEADER:2E3,INVALID_TEXT_CUE:2001,INVALID_TEXT_SETTINGS:2002,UNABLE_TO_DETECT_ENCODING:2003,BAD_ENCODING:2004,BUFFER_READ_OUT_OF_BOUNDS:3E3,JS_INTEGER_OVERFLOW:3001,EBML_OVERFLOW:3002,EBML_BAD_FLOATING_POINT_SIZE:3003,MP4_SIDX_WRONG_BOX_TYPE:3004,MP4_SIDX_INVALID_TIMESCALE:3005,MP4_SIDX_TYPE_NOT_SUPPORTED:3006,WEBM_CUES_ELEMENT_MISSING:3007,WEBM_EBML_HEADER_ELEMENT_MISSING:3008, WEBM_SEGMENT_ELEMENT_MISSING:3009,WEBM_INFO_ELEMENT_MISSING:3010,WEBM_DURATION_ELEMENT_MISSING:3011,WEBM_CUE_TRACK_POSITIONS_ELEMENT_MISSING:3012,WEBM_CUE_TIME_ELEMENT_MISSING:3013,MEDIA_SOURCE_OPERATION_FAILED:3014,MEDIA_SOURCE_OPERATION_THREW:3015,VIDEO_ERROR:3016,UNABLE_TO_GUESS_MANIFEST_TYPE:4E3,DASH_INVALID_XML:4001,DASH_NO_SEGMENT_INFO:4002,DASH_EMPTY_ADAPTATION_SET:4003,DASH_EMPTY_PERIOD:4004,DASH_WEBM_MISSING_INIT:4005,DASH_UNSUPPORTED_CONTAINER:4006,DASH_PSSH_BAD_ENCODING:4007,DASH_NO_COMMON_KEY_SYSTEM:4008, DASH_MULTIPLE_KEY_IDS_NOT_SUPPORTED:4009,DASH_CONFLICTING_KEY_IDS:4010,UNPLAYABLE_PERIOD:4011,INCONSISTENT_BUFFER_STATE:5E3,INVALID_SEGMENT_INDEX:5001,SEGMENT_DOES_NOT_EXIST:5002,BAD_SEGMENT:5004,INVALID_STREAMS_CHOSEN:5005,NO_RECOGNIZED_KEY_SYSTEMS:6E3,REQUESTED_KEY_SYSTEMS_UNAVAILABLE:6001,FAILED_TO_CREATE_CDM:6002,FAILED_TO_ATTACH_TO_VIDEO:6003,INVALID_SERVER_CERTIFICATE:6004,FAILED_TO_CREATE_SESSION:6005,FAILED_TO_GENERATE_LICENSE_REQUEST:6006,LICENSE_REQUEST_FAILED:6007,LICENSE_RESPONSE_REJECTED:6008, ENCRYPTED_CONTENT_WITHOUT_DRM_INFO:6010};function Oa(a){this.b=a;this.c=0==Pa;this.a=0}var Pa=1;function Qa(a){return a.a<a.b.byteLength}function Ra(a){try{var b=a.b.getUint8(a.a)}catch(c){Sa()}a.a+=1;return b}function A(a){try{var b=a.b.getUint32(a.a,a.c)}catch(c){Sa()}a.a+=4;return b}function Ua(a){var b,c;try{a.c?(b=a.b.getUint32(a.a,!0),c=a.b.getUint32(a.a+4,!0)):(c=a.b.getUint32(a.a,!1),b=a.b.getUint32(a.a+4,!1))}catch(d){Sa()}if(2097151<c)throw new x(3,3001);a.a+=8;return c*Math.pow(2,32)+b} function Va(a){a.a+16>a.b.byteLength&&Sa();var b=new Uint8Array(a.b.buffer,a.a,16);a.a+=16;return b}function B(a,b){a.a+b>a.b.byteLength&&Sa();a.a+=b}function Sa(){throw new x(3,3E3);};function C(a){this.b=a;this.a=new Oa(a);Wa||(Wa=[new Uint8Array([255]),new Uint8Array([127,255]),new Uint8Array([63,255,255]),new Uint8Array([31,255,255,255]),new Uint8Array([15,255,255,255,255]),new Uint8Array([7,255,255,255,255,255]),new Uint8Array([3,255,255,255,255,255,255]),new Uint8Array([1,255,255,255,255,255,255,255])])}var Wa; function D(a){var b;b=Xa(a);if(7<b.length)throw new x(3,3002);for(var c=0,d=0;d<b.length;d++)c=256*c+b[d];b=c;c=Xa(a);a:{for(d=0;d<Wa.length;d++)if(E(c,Wa[d])){d=!0;break a}d=!1}if(d)c=a.b.byteLength-a.a.a;else{if(8==c.length&&c[1]&224)throw new x(3,3001);for(var d=c[0]&(1<<8-c.length)-1,e=1;e<c.length;e++)d=256*d+c[e];c=d}c=a.a.a+c<=a.b.byteLength?c:a.b.byteLength-a.a.a;d=new DataView(a.b.buffer,a.b.byteOffset+a.a.a,c);B(a.a,c);return new Ya(b,d)} function Xa(a){var b=Ra(a.a),c;for(c=1;8>=c&&!(b&1<<8-c);c++);if(8<c)throw new x(3,3002);var d=new Uint8Array(c);d[0]=b;for(b=1;b<c;b++)d[b]=Ra(a.a);return d}function Ya(a,b){this.id=a;this.a=b}function Za(a){if(8<a.a.byteLength)throw new x(3,3002);if(8==a.a.byteLength&&a.a.getUint8(0)&224)throw new x(3,3001);for(var b=0,c=0;c<a.a.byteLength;c++)var d=a.a.getUint8(c),b=256*b+d;return b};function F(a,b){var c=b||{},d;for(d in c)this[d]=c[d];this.defaultPrevented=this.cancelable=this.bubbles=!1;this.timeStamp=window.performance?window.performance.now():Date.now();this.type=a;this.isTrusted=!1;this.target=this.currentTarget=null;this.a=!1}F.prototype.preventDefault=function(){};F.prototype.stopImmediatePropagation=function(){this.a=!0};F.prototype.stopPropagation=function(){};function $a(a,b){return a.reduce(function(a,b,e){return b["catch"](a.bind(null,e))}.bind(null,b),Promise.reject())}function ab(a,b){return a.concat(b)}function G(){}function H(a){return null!=a}function bb(a){return function(b){return b!=a}};function I(a){this.a=a}m("shaka.media.SegmentIndex",I);I.prototype.u=function(){this.a=null;return Promise.resolve()};I.prototype.b=function(a){for(var b=this.a.length-1;0<=b;--b){var c=this.a[b];if(a>=c.startTime&&a<c.a)return c.position}return null};I.prototype.get=function(a){if(0==this.a.length)return null;a-=this.a[0].position;return 0>a||a>=this.a.length?null:this.a[a]}; function cb(a,b){for(var c=[],d=0,e=0;d<a.a.length&&e<b.length;){var f=a.a[d],g=b[e];f.startTime<g.startTime?(c.push(f),d++):(f.startTime>g.startTime||(f.a!=g.a?c.push(g):c.push(f),d++),e++)}for(;d<a.a.length;)c.push(a.a[d++]);if(c.length)for(d=c[c.length-1].position+1;e<b.length;)g=b[e++],g=new v(d++,g.startTime,g.a,g.uris,g.c,g.b),c.push(g);else c=b;a.a=c}function db(a,b){for(var c=0;c<a.a.length&&!(a.a[c].a>b);++c);a.a.splice(0,c)};function eb(a,b){this.g=fb[b];this.c=a;this.h=0;this.f=Number.POSITIVE_INFINITY;this.a=this.b=null}var fb={};m("shaka.media.TextEngine.registerParser",function(a,b){fb[a]=b});m("shaka.media.TextEngine.unregisterParser",function(a){delete fb[a]});eb.prototype.u=function(){this.c&&gb(this,function(){return!0});this.c=this.g=null;return Promise.resolve()}; function hb(a,b,c,d){var e=a.h;c+=e;d+=e;return Promise.resolve().then(function(){for(var a=this.g(b),g=0;g<a.length;++g){a[g].startTime+=e;a[g].endTime+=e;if(a[g].startTime>=this.f)break;this.c.addCue(a[g])}null==this.b&&(this.b=c);this.a=Math.min(d,this.f)}.bind(a))} function ib(a,b,c){return Promise.resolve().then(function(){gb(this,function(a){return a.startTime>=c||a.endTime<=b?!1:!0});null==this.b||c<=this.b||b>=this.a||(b<=this.b&&c>=this.a?this.b=this.a=null:b<=this.b&&c<this.a?this.b=c:b>this.b&&c>=this.a&&(this.a=b))}.bind(a))}function jb(a,b){return null==a.a||a.a<b||b<a.b?0:a.a-b}function gb(a,b){for(var c=a.c.cues,d=[],e=0;e<c.length;++e)b(c[e])&&d.push(c[e]);for(e=0;e<d.length;++e)a.c.removeCue(d[e])};function kb(a){a=a.toLowerCase().split("-");var b=lb[a[0]];b&&(a[0]=b);return a.join("-")} var lb={aar:"aa",abk:"ab",afr:"af",aka:"ak",alb:"sq",amh:"am",ara:"ar",arg:"an",arm:"hy",asm:"as",ava:"av",ave:"ae",aym:"ay",aze:"az",bak:"ba",bam:"bm",baq:"eu",bel:"be",ben:"bn",bih:"bh",bis:"bi",bod:"bo",bos:"bs",bre:"br",bul:"bg",bur:"my",cat:"ca",ces:"cs",cha:"ch",che:"ce",chi:"zh",chu:"cu",chv:"cv",cor:"kw",cos:"co",cre:"cr",cym:"cy",cze:"cs",dan:"da",deu:"de",div:"dv",dut:"nl",dzo:"dz",ell:"el",eng:"en",epo:"eo",est:"et",eus:"eu",ewe:"ee",fao:"fo",fas:"fa",fij:"fj",fin:"fi",fra:"fr",fre:"fr", fry:"fy",ful:"ff",geo:"ka",ger:"de",gla:"gd",gle:"ga",glg:"gl",glv:"gv",gre:"el",grn:"gn",guj:"gu",hat:"ht",hau:"ha",heb:"he",her:"hz",hin:"hi",hmo:"ho",hrv:"hr",hun:"hu",hye:"hy",ibo:"ig",ice:"is",ido:"io",iii:"ii",iku:"iu",ile:"ie",ina:"ia",ind:"id",ipk:"ik",isl:"is",ita:"it",jav:"jv",jpn:"ja",kal:"kl",kan:"kn",kas:"ks",kat:"ka",kau:"kr",kaz:"kk",khm:"km",kik:"ki",kin:"rw",kir:"ky",kom:"kv",kon:"kg",kor:"ko",kua:"kj",kur:"ku",lao:"lo",lat:"la",lav:"lv",lim:"li",lin:"ln",lit:"lt",ltz:"lb",lub:"lu", lug:"lg",mac:"mk",mah:"mh",mal:"ml",mao:"mi",mar:"mr",may:"ms",mkd:"mk",mlg:"mg",mlt:"mt",mon:"mn",mri:"mi",msa:"ms",mya:"my",nau:"na",nav:"nv",nbl:"nr",nde:"nd",ndo:"ng",nep:"ne",nld:"nl",nno:"nn",nob:"nb",nor:"no",nya:"ny",oci:"oc",oji:"oj",ori:"or",orm:"om",oss:"os",pan:"pa",per:"fa",pli:"pi",pol:"pl",por:"pt",pus:"ps",que:"qu",roh:"rm",ron:"ro",rum:"ro",run:"rn",rus:"ru",sag:"sg",san:"sa",sin:"si",slk:"sk",slo:"sk",slv:"sl",sme:"se",smo:"sm",sna:"sn",snd:"sd",som:"so",sot:"st",spa:"es",sqi:"sq", srd:"sc",srp:"sr",ssw:"ss",sun:"su",swa:"sw",swe:"sv",tah:"ty",tam:"ta",tat:"tt",tel:"te",tgk:"tg",tgl:"tl",tha:"th",tib:"bo",tir:"ti",ton:"to",tsn:"tn",tso:"ts",tuk:"tk",tur:"tr",twi:"tw",uig:"ug",ukr:"uk",urd:"ur",uzb:"uz",ven:"ve",vie:"vi",vol:"vo",wel:"cy",wln:"wa",wol:"wo",xho:"xh",yid:"yi",yor:"yo",zha:"za",zho:"zh",zul:"zu"};function K(a){return Object.keys(a).map(function(b){return a[b]})}function mb(a,b){return Object.keys(a).reduce(function(c,d){c[d]=b(a[d],d);return c},{})};function L(){this.a={}}L.prototype.push=function(a,b){this.a.hasOwnProperty(a)?this.a[a].push(b):this.a[a]=[b]};L.prototype.get=function(a){return(a=this.a[a])?a.slice():null};function nb(a,b,c){if(a=a.a[b])for(b=0;b<a.length;++b)a[b]==c&&(a.splice(b,1),--b)}L.prototype.keys=function(){var a=[],b;for(b in this.a)a.push(b);return a};function M(){this.a=new L}M.prototype.u=function(){ob(this);this.a=null;return Promise.resolve()};function N(a,b,c,d){b=new pb(b,c,d);a.a.push(c,b)}M.prototype.ea=function(a,b){for(var c=this.a.get(b)||[],d=0;d<c.length;++d){var e=c[d];e.target==a&&(e.ea(),nb(this.a,b,e))}};function ob(a){var b=a.a,c=[],d;for(d in b.a)c.push.apply(c,b.a[d]);for(b=0;b<c.length;++b)c[b].ea();a.a.a={}}function pb(a,b,c){this.target=a;this.type=b;this.a=c;this.target.addEventListener(b,c,!1)} pb.prototype.ea=function(){this.target&&(this.target.removeEventListener(this.type,this.a,!1),this.a=this.target=null)};function qb(a,b,c,d,e,f){this.a=a;this.b=b;this.l=c;this.g=e;this.m=f;this.c=new M;this.f=!1;this.h=0;null==d&&(d=b.a<Number.POSITIVE_INFINITY?p(b):Math.max(pa(b)-c,p(b)));this.o=d;0<a.readyState?this.i():N(this.c,a,"loadedmetadata",this.i.bind(this))}qb.prototype.u=function(){var a=this.c.u();this.m=this.g=this.b=this.a=this.c=null;return a};function rb(a){return sb(a,0<a.a.readyState?a.a.currentTime:a.o)} function tb(a,b){b&&!a.f?(a.h=a.a.playbackRate,a.a.playbackRate=0,a.f=!0,a.g(!0)):!b&&a.f&&(0==a.a.playbackRate&&(a.a.playbackRate=a.h),a.f=!1,a.g(!1))}qb.prototype.i=function(){this.c.ea(this.a,"loadedmetadata");N(this.c,this.a,"seeking",this.v.bind(this));var a=sb(this,this.o);this.a.currentTime!=a&&(this.a.currentTime=a)}; qb.prototype.v=function(){var a=this.a.currentTime,b=ub(this,a);if(b!=a){this.a.currentTime=b;var c=0,d=function(){!this.a||10<=c++||this.a.currentTime!=a||(this.a.currentTime=b,setTimeout(d,100))}.bind(this);setTimeout(d,100)}else this.m()};function ub(a,b){var c=a.b.b,d=p(a.b),e=pa(a.b);if(!(null!=c&&c<Number.POSITIVE_INFINITY))return b<d?d:b>e?e:b;c=d+1;d=c+a.l;return b>=d&&b<=e||0!=ra(a.a.buffered,b)&&b>=c&&b<=e?b:b>e?e:e<d&&b>=c&&b<=e?b:Math.min(d+2,e)} function sb(a,b){var c=p(a.b);if(b<c)return c;c=pa(a.b);return b>c?c:b};function ca(){this.v=new L}ca.prototype.addEventListener=function(a,b){this.v.push(a,b)};ca.prototype.removeEventListener=function(a,b){nb(this.v,a,b)};ca.prototype.dispatchEvent=function(a){for(var b=this.v.get(a.type)||[],c=0;c<b.length;++c){a.target=this;a.currentTarget=this;var d=b[c];try{d.handleEvent?d.handleEvent(a):d.call(this,a)}catch(e){}if(a.a)break}return a.defaultPrevented};function O(){var a,b,c=new Promise(function(c,e){a=c;b=e});c.resolve=a;c.reject=b;return c};function vb(a,b,c){this.i=a;this.f=b;this.l=c;this.c={};this.b=null;this.a={};this.g=new M;this.h=!1} function wb(){var a={basic:!!window.MediaSource},b=navigator.vendor,c=navigator.appVersion;b&&0<=b.indexOf("Apple")&&c&&0<=c.indexOf("Version/8")&&(a.basic=!1);a.basic&&'video/mp4; codecs="avc1.42E01E",audio/mp4; codecs="mp4a.40.2",video/webm; codecs="vp8",video/webm; codecs="vp9",audio/webm; codecs="vorbis",audio/webm; codecs="opus",video/mp2t; codecs="avc1.42E01E",video/mp2t; codecs="mp4a.40.2",text/vtt,application/mp4; codecs="wvtt",application/ttml+xml,application/mp4; codecs="stpp"'.split(",").forEach(function(b){a[b]=!!fb[b]|| MediaSource.isTypeSupported(b);var c=b.split(";")[0];a[c]=a[c]||a[b]});return a}k=vb.prototype;k.u=function(){this.h=!0;var a=[],b;for(b in this.a){var c=this.a[b],d=c[0];this.a[b]=c.slice(0,1);d&&a.push(d.p["catch"](G));for(d=1;d<c.length;++d)c[d].p["catch"](G),c[d].p.reject()}this.b&&a.push(this.b.u());return Promise.all(a).then(function(){this.g.u();this.b=this.l=this.f=this.i=this.g=null;this.c={};this.a={}}.bind(this))}; k.init=function(a){for(var b in a){var c=a[b];"text"==b?this.b=new eb(this.l,c):(c=this.f.addSourceBuffer(c),N(this.g,c,"error",this.zb.bind(this,b)),N(this.g,c,"updateend",this.za.bind(this,b)),this.c[b]=c,this.a[b]=[])}};function xb(a,b){var c;c="text"==b?a.b.b:(c=a.c[b].buffered)?c.length?c.start(0):null:null;return c}function yb(a,b,c,d){"text"==b?(b=jb(a.b,c),!b&&d&&(b=jb(a.b,c+d))&&(b+=d)):(a=a.c[b].buffered,b=ra(a,c),!b&&d&&(b=ra(a,c+d))&&(b+=d));return b} function zb(a,b,c,d,e){return"text"==b?hb(a.b,c,d,e):Ab(a,b,a.yb.bind(a,b,c))}function Bb(a,b){return"text"==b?ib(a.b,0,Number.POSITIVE_INFINITY):Ab(a,b,a.Ha.bind(a,b,0,a.f.duration))}function Cb(a,b,c){return"text"==b?(a.b.h=c,Promise.resolve()):Ab(a,b,a.rb.bind(a,b,c))}function Db(a,b,c){return"text"==b?(a.b.f=c,Promise.resolve()):Ab(a,b,a.pb.bind(a,b,c))}k.endOfStream=function(a){return Fb(this,function(){a?this.f.endOfStream(a):this.f.endOfStream()}.bind(this))}; function Gb(a,b){Fb(a,function(){this.f.duration=b}.bind(a))}k.yb=function(a,b){this.c[a].appendBuffer(b)};k.Ha=function(a,b,c){this.c[a].remove(b,c)};k.rb=function(a,b){this.c[a].timestampOffset=b;this.za(a)};k.pb=function(a,b){this.c[a].appendWindowEnd=b+1/15;this.za(a)};k.zb=function(a){this.a[a][0].p.reject(new x(3,3014,this.i.error?this.i.error.code:0))};k.za=function(a){this.a[a][0].p.resolve();Hb(this,a)}; function Ab(a,b,c){if(a.h)return Promise.reject();c={start:c,p:new O};a.a[b].push(c);if(1==a.a[b].length)try{c.start()}catch(d){c.p.reject(new x(3,3015,d)),Hb(a,b)}return c.p} function Fb(a,b){if(a.h)return Promise.reject();var c=[],d;for(d in a.c){var e=new O,f={start:function(a){a.resolve()}.bind(null,e),p:e};a.a[d].push(f);c.push(e);1==a.a[d].length&&f.start()}return Promise.all(c).then(function(){var a,c;try{b()}catch(d){c=Promise.reject(new x(3,3015,d))}for(a in this.c)Hb(this,a);return c}.bind(a),function(){return Promise.reject()}.bind(a))}function Hb(a,b){a.a[b].shift();var c=a.a[b][0];if(c)try{c.start()}catch(d){c.p.reject(new x(3,3015,d)),Hb(a,b)}};function Ib(a){if(!a)return"";a=String.fromCharCode.apply(null,new Uint8Array(a));a=escape(a);try{return decodeURIComponent(a)}catch(b){throw new x(2,2004);}}function Jb(a,b){if(!a)return"";if(0!=a.byteLength%2)throw new x(2,2004);var c;if(a instanceof ArrayBuffer)c=a;else{var d=new Uint8Array(a.byteLength);d.set(new Uint8Array(a));c=d.buffer}var d=[],e=a.byteLength/2;c=new DataView(c);for(var f=0;f<e;f++)d[f]=c.getUint16(2*f,b);return String.fromCharCode.apply(null,d)} function Kb(a){var b=new Uint8Array(a);if(239==b[0]&&187==b[1]&&191==b[2])return Ib(b.subarray(3));if(254==b[0]&&255==b[1])return Jb(b.subarray(2),!1);if(255==b[0]&&254==b[1])return Jb(b.subarray(2),!0);var c=function(a,b){return a.byteLength<=b||32<=a[b]&&126>=a[b]}.bind(null,b);if(0==b[0]&&0==b[2])return Jb(a,!1);if(0==b[1]&&0==b[3])return Jb(a,!0);if(c(0)&&c(1)&&c(2)&&c(3))return Ib(a);throw new x(2,2003);} function Lb(a){a=unescape(encodeURIComponent(a));for(var b=new Uint8Array(a.length),c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b.buffer};function Mb(a){this.b=a;this.a=0}function Nb(a,b){var c;b.lastIndex=a.a;c=b.exec(a.b);c=null==c?null:{position:c.index,length:c[0].length,nb:c};if(a.a==a.b.length||null==c||c.position!=a.a)return null;a.a+=c.length;return c.nb}function Ob(a){return a.a==a.b.length?null:(a=Nb(a,/[^ \t\n]*/gm))?a[0]:null};function P(a){a=Kb(a);a=a.replace(/\r\n|\r(?=[^\n]|$)/gm,"\n");a=a.split(/\n{2,}/m);if(!/^WEBVTT($|[ \t\n])/m.test(a[0]))throw new x(2,2E3);for(var b=[],c=1;c<a.length;c++){var d=P.b(a[c].split("\n"));d&&b.push(d)}return b} P.b=function(a){if(1==a.length&&!a[0]||/^NOTE($|[ \t])/.test(a[0]))return null;var b=null;0>a[0].indexOf("--\x3e")&&(b=a[0],a.splice(0,1));var c=new Mb(a[0]),d=P.a(c),e=Nb(c,/[ \t]+--\x3e[ \t]+/g),f=P.a(c);if(null==d||null==e||null==f)throw new x(2,2001);a=a.slice(1).join("\n");if(window.VTTCue)for(d=new VTTCue(d,f,a),Nb(c,/[ \t]+/gm),f=Ob(c);f;){if(!P.c(d,f))throw new x(2,2002);Nb(c,/[ \t]+/gm);f=Ob(c)}else d=new TextTrackCue(d,f,a);null!=b&&(d.id=b);return d}; P.c=function(a,b){var c=null;if(c=/^align:(start|middle|end)$/.exec(b))a.align=c[1];else if(c=/^vertical:(lr|rl)$/.exec(b))a.c=c[1];else if(c=/^size:(\d{1,2}|100)%$/.exec(b))a.size=Number(c[1]);else if(c=/^position:(\d{1,2}|100)%$/.exec(b))a.position=Number(c[1]);else if(c=/^line:(\d{1,2}|100)%$/.exec(b))a.b=!1,a.a=Number(c[1]);else if(c=/^line:(-?\d+)$/.exec(b))a.b=!0,a.a=Number(c[1]);else return!1;return!0}; P.a=function(a){a=Nb(a,/(?:(\d{2,}):)?(\d{2}):(\d{2})\.(\d{3})/g);if(null==a)return null;var b=Number(a[2]),c=Number(a[3]);return 59<b||59<c?null:Number(a[4])/1E3+c+60*b+3600*(Number(a[1])||0)};fb["text/vtt"]=P;function Pb(a){return window.btoa(String.fromCharCode.apply(null,a)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=*$/,"")}function Qb(a){a=window.atob(a.replace(/-/g,"+").replace(/_/g,"/"));for(var b=new Uint8Array(a.length),c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b}function Rb(a){for(var b=new Uint8Array(a.length/2),c=0;c<a.length;c+=2)b[c/2]=window.parseInt(a.substr(c,2),16);return b} function Sb(a){for(var b="",c=0;c<a.length;++c){var d=a[c].toString(16);1==d.length&&(d="0"+d);b+=d}return b}function E(a,b){if(!a&&!b)return!0;if(!a||!b||a.length!=b.length)return!1;for(var c=0;c<a.length;++c)if(a[c]!=b[c])return!1;return!0};function Tb(a,b,c){this.h="";this.m=[];this.l=this.g=null;this.o=!1;this.f=new M;this.v="";this.a=[];this.B=a;this.c=null;this.i=b;this.G=c;this.b=!1}k=Tb.prototype;k.u=function(){this.b=!0;this.a.forEach(function(a){a.Aa.close()["catch"](G)});var a=[];this.f&&a.push(this.f.u());this.l&&a.push(this.l.setMediaKeys(null)["catch"](G));this.m=[];this.f=this.l=this.g=null;this.a=[];this.i=this.c=this.B=null;return Promise.all(a)};k.configure=function(a){this.c=a}; k.init=function(a,b){var c={},d=[];Ub(this,a,b,c,d);return d.length?Vb(this,c,d):(this.o=!0,Promise.resolve())}; function Wb(a,b){if(!a.g)return N(a.f,b,"encrypted",function(){this.f.ea(b,"encrypted");this.i(new x(6,6010))}.bind(a)),Promise.resolve();var c=[],d=[],e=[];Xb(a,c,d,e);a.v=c[0];a.l=b;var c=a.l.setMediaKeys(a.g),c=c["catch"](function(a){return Promise.reject(new x(6,6003,a.message))}),f=null;d.length&&(f=a.g.setServerCertificate(d[0]),f=f["catch"](function(a){return Promise.reject(new x(6,6004,a.message))}));return Promise.all([c,f]).then(function(){if(this.b)return Promise.reject();e.length?e.forEach(function(a){Yb(this, a.initDataType,a.initData)}.bind(this)):N(this.f,this.l,"encrypted",this.Wa.bind(this))}.bind(a))["catch"](function(a){return this.b?Promise.resolve():Promise.reject(a)}.bind(a))}k.keySystem=function(){return this.h}; function Ub(a,b,c,d,e){var f=Zb(a);b.periods.forEach(function(a){a.streamSets.forEach(function(a){"text"!=a.type&&(f&&(a.drmInfos=[f]),a.drmInfos.forEach(function(b){$b(this,b);var f=d[b.keySystem];f||(f={initDataTypes:void 0,audioCapabilities:[],videoCapabilities:[],distinctiveIdentifier:"optional",persistentState:c?"required":"optional",sessionTypes:[c?"persistent-license":"temporary"],label:b.keySystem,mimeTypes:{},drmInfos:[]},d[b.keySystem]=f,e.push(b.keySystem));f.drmInfos.push(b);b.distinctiveIdentifierRequired&& (f.distinctiveIdentifier="required");b.persistentStateRequired&&(f.persistentState="required");var g="video"==a.type?f.videoCapabilities:f.audioCapabilities,t=("video"==a.type?b.videoRobustness:b.audioRobustness)||"";a.streams.forEach(function(a){a=a.mimeType;f.mimeTypes[a]||(g.push({robustness:t,contentType:a}),f.mimeTypes[a]=!0)}.bind(this))}.bind(this)))}.bind(this))}.bind(a))} function Vb(a,b,c){var d=new O,e=d;if(1==c.length&&""==c[0])return Promise.reject(new x(6,6E3));c.forEach(function(a){var c=b[a];c.drmInfos.some(function(a){return!!a.licenseServerUri})&&(0==c.audioCapabilities.length&&(c.audioCapabilities=void 0),0==c.videoCapabilities.length&&(c.videoCapabilities=void 0),e=e["catch"](function(){return this.b?Promise.reject():navigator.requestMediaKeySystemAccess(a,[c])}.bind(this)))}.bind(a));e=e["catch"](function(){return Promise.reject(new x(6,6001))});e=e.then(function(a){if(this.b)return Promise.reject(); this.m=b[a.keySystem].drmInfos;this.h=a.keySystem;return a.createMediaKeys()}.bind(a)).then(function(a){if(this.b)return Promise.reject();this.g=a;this.o=!0}.bind(a))["catch"](function(a){if(this.b)return Promise.resolve();if(a instanceof x)return Promise.reject(a);this.h="";this.m=[];return Promise.reject(new x(6,6002,a.message))}.bind(a));d.reject();return e} function $b(a,b){var c=b.keySystem;if(c){if(!b.licenseServerUri){var d=a.c.servers[c];d&&(b.licenseServerUri=d)}if(c=a.c.advanced[c])b.distinctiveIdentifierRequired||(b.distinctiveIdentifierRequired=c.distinctiveIdentifierRequired),b.persistentStateRequired||(b.persistentStateRequired=c.persistentStateRequired),b.videoRobustness||(b.videoRobustness=c.videoRobustness),b.audioRobustness||(b.audioRobustness=c.audioRobustness),b.serverCertificate||(b.serverCertificate=c.serverCertificate)}} function Zb(a){var b=a.c.clearKeys;if(!b||0==Object.keys(b).length)return null;var c=[],b=[],d;for(d in a.c.clearKeys){var e=a.c.clearKeys[d],f=Rb(d),e=Rb(e),f={kty:"oct",kid:Pb(f),k:Pb(e)};c.push(f);b.push(f.kid)}a=JSON.stringify({keys:c});b=JSON.stringify({kids:b});b=[{initData:new Uint8Array(Lb(b)),initDataType:"keyids"}];return{keySystem:"org.w3.clearkey",licenseServerUri:"data:application/json;base64,"+window.btoa(a),distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"", videoRobustness:"",serverCertificate:null,initData:b}}function Xb(a,b,c,d){function e(a,b){return a.initDataType==b.initDataType&&E(a.initData,b.initData)}a.m.forEach(function(a){-1==b.indexOf(a.licenseServerUri)&&b.push(a.licenseServerUri);a.serverCertificate&&-1==Na(c,a.serverCertificate,E)&&c.push(a.serverCertificate);a.initData&&a.initData.forEach(function(a){-1==Na(d,a,e)&&d.push(a)})})} k.Wa=function(a){for(var b=new Uint8Array(a.initData),c=0;c<this.a.length;++c)if(E(b,this.a[c].initData))return;Yb(this,a.initDataType,b)}; function Yb(a,b,c){var d;try{d=a.g.createSession()}catch(e){a.i(new x(6,6005,e.message));return}N(a.f,d,"message",a.ab.bind(a));N(a.f,d,"keystatuseschange",a.Xa.bind(a));b=d.generateRequest(b,c.buffer);a.a.push({initData:c,Aa:d});b["catch"](function(a){if(!this.b){for(var b=0;b<this.a.length;++b)if(this.a[b].Aa==d){this.a.splice(b,1);break}this.i(new x(6,6006,a.message))}}.bind(a))} k.ab=function(a){var b=a.target,c=ac,d=bc([this.v],this.c.retryParameters);d.body=a.message;d.method="POST";"com.microsoft.playready"==this.h&&cc(d);this.B.request(c,d).then(function(a){return this.b?Promise.reject():b.update(a.data)}.bind(this),function(a){if(this.b)return Promise.resolve();this.i(new x(6,6007,a))}.bind(this))["catch"](function(a){if(this.b)return Promise.resolve();this.i(new x(6,6008,a.message))}.bind(this))}; function cc(a){for(var b=Jb(a.body,!0),b=(new DOMParser).parseFromString(b,"application/xml"),c=b.getElementsByTagName("HttpHeader"),d=0;d<c.length;++d)a.headers[c[d].querySelector("name").textContent]=c[d].querySelector("value").textContent;a.body=Qb(b.querySelector("Challenge").textContent).buffer} k.Xa=function(a){a=a.target;var b={};a.keyStatuses.forEach(function(a,c){if("string"==typeof a){var f=a;a=c;c=f}if("com.microsoft.playready"==this.h&&16==a.byteLength){var f=new DataView(a),g=f.getUint32(0,!0),h=f.getUint16(4,!0),l=f.getUint16(6,!0);f.setUint32(0,g,!1);f.setUint16(4,h,!1);f.setUint16(6,l,!1)}"com.microsoft.playready"==this.h&&"status-pending"==c&&(c="usable");f=Sb(new Uint8Array(a));b[f]=c}.bind(this));if(a.expiration<Date.now()){for(var c=0;c<this.a.length;++c)if(this.a[c].Aa==a){this.a.splice(c, 1);break}a.close()}this.G(b)}; function dc(){var a={basic:!!window.MediaKeys&&!!window.navigator&&!!window.navigator.requestMediaKeySystemAccess&&!!window.MediaKeySystemAccess&&!!window.MediaKeySystemAccess.prototype.getConfiguration},b=[];a.basic&&"org.w3.clearkey com.widevine.alpha com.microsoft.playready com.apple.fps.2_0 com.apple.fps.1_0 com.apple.fps com.adobe.primetime".split(" ").forEach(function(c){var d=navigator.requestMediaKeySystemAccess(c,[{}]).then(function(){a[c]=!0},function(){a[c]=!1});b.push(d)});return Promise.all(b).then(function(){return a})} ;function ec(a,b){try{var c=new fc(a,b);return Promise.resolve(c)}catch(d){return Promise.reject(d)}}function gc(a){var b=this.mediaKeys;b&&b!=a&&hc(b,null);delete this.mediaKeys;(this.mediaKeys=a)&&hc(a,this);return Promise.resolve()} function fc(a,b){this.a=this.keySystem=a;var c=!0;"org.w3.clearkey"==a&&(this.a="webkit-org.w3.clearkey",c=!1);var d=!1,e;e=document.getElementsByTagName("video");e=e.length?e[0]:document.createElement("video");for(var f=0;f<b.length;++f){var g=b[f],h={audioCapabilities:[],videoCapabilities:[],persistentState:"optional",distinctiveIdentifier:"optional",initDataTypes:g.initDataTypes,sessionTypes:["temporary"],label:g.label},l=!1;if(g.audioCapabilities)for(var n=0;n<g.audioCapabilities.length;++n){var q= g.audioCapabilities[n];q.contentType&&(l=!0,e.canPlayType(q.contentType.split(";")[0],this.a)&&(h.audioCapabilities.push(q),d=!0))}if(g.videoCapabilities)for(n=0;n<g.videoCapabilities.length;++n)q=g.videoCapabilities[n],q.contentType&&(l=!0,e.canPlayType(q.contentType,this.a)&&(h.videoCapabilities.push(q),d=!0));l||(d=e.canPlayType("video/mp4",this.a)||e.canPlayType("video/webm",this.a));"required"==g.persistentState&&(c?(h.persistentState="required",h.sessionTypes=["persistent-license"]):d=!1);if(d){this.b= h;return}}c="Unsupported keySystem";if("org.w3.clearkey"==a||"com.widevine.alpha"==a)c="None of the requested configurations were supported.";c=Error(c);c.name="NotSupportedError";c.code=DOMException.NOT_SUPPORTED_ERR;throw c;}fc.prototype.createMediaKeys=function(){var a=new ic(this.a);return Promise.resolve(a)};fc.prototype.getConfiguration=function(){return this.b};function ic(a){this.g=a;this.b=null;this.a=new M;this.c=[];this.f={}} function hc(a,b){a.b=b;ob(a.a);b&&(N(a.a,b,"webkitneedkey",a.gb.bind(a)),N(a.a,b,"webkitkeymessage",a.fb.bind(a)),N(a.a,b,"webkitkeyadded",a.cb.bind(a)),N(a.a,b,"webkitkeyerror",a.eb.bind(a)))}k=ic.prototype;k.createSession=function(a){var b=a||"temporary";if("temporary"!=b&&"persistent-license"!=b)throw new TypeError("Session type "+a+" is unsupported on this platform.");a=this.b||document.createElement("video");a.src||(a.src="about:blank");b=new jc(a,this.g,b);this.c.push(b);return b}; k.setServerCertificate=function(){return Promise.reject(Error("setServerCertificate not supported on this platform."))};k.gb=function(a){this.b.dispatchEvent(new F("encrypted",{initDataType:"webm",initData:a.initData}))};k.fb=function(a){var b=kc(this,a.sessionId);b&&(a=new F("message",{messageType:void 0==b.keyStatuses.wa()?"licenserequest":"licenserenewal",message:a.message}),b.b&&(b.b.resolve(),b.b=null),b.dispatchEvent(a))}; k.cb=function(a){if(a=kc(this,a.sessionId))lc(a,"usable"),a.a&&a.a.resolve(),a.a=null}; k.eb=function(a){var b=kc(this,a.sessionId);if(b){var c=Error("EME v0.1b key error");c.errorCode=a.errorCode;c.errorCode.systemCode=a.systemCode;!a.sessionId&&b.b?(c.method="generateRequest",45==a.systemCode&&(c.message="Unsupported session type."),b.b.reject(c),b.b=null):a.sessionId&&b.a?(c.method="update",b.a.reject(c),b.a=null):(c=a.systemCode,a.errorCode.code==MediaKeyError.MEDIA_KEYERR_OUTPUT?lc(b,"output-restricted"):1==c?lc(b,"expired"):lc(b,"internal-error"))}}; function kc(a,b){var c=a.f[b];return c?c:(c=a.c.shift())?(c.sessionId=b,a.f[b]=c):null}function jc(a,b,c){this.v=new L;this.f=a;this.h=!1;this.a=this.b=null;this.c=b;this.g=c;this.sessionId="";this.expiration=NaN;this.closed=new O;this.keyStatuses=new mc}ba(jc); function nc(a,b,c){if(a.h)return Promise.reject(Error("The session is already initialized."));a.h=!0;var d;try{if("persistent-license"==a.g)if(c)d=new Uint8Array(Lb("LOAD_SESSION|"+c));else{var e=Lb("PERSISTENT|"),f=new Uint8Array(e.byteLength+b.byteLength);f.set(new Uint8Array(e),0);f.set(new Uint8Array(b),e.byteLength);d=f}else d=new Uint8Array(b)}catch(g){return Promise.reject(g)}a.b=new O;try{a.f.webkitGenerateKeyRequest(a.c,d)}catch(g){if("InvalidStateError"!=g.name)return a.b=null,Promise.reject(g); setTimeout(function(){try{this.f.webkitGenerateKeyRequest(this.c,d)}catch(a){this.b.reject(a),this.b=null}}.bind(a),10)}return a.b}k=jc.prototype; k.Da=function(a,b){if(this.a)this.a.then(this.Da.bind(this,a,b))["catch"](this.Da.bind(this,a,b));else{this.a=a;var c,d;"webkit-org.w3.clearkey"==this.c?(c=Ib(b),d=JSON.parse(c),"oct"!=d.keys[0].kty&&(this.a.reject(Error("Response is not a valid JSON Web Key Set.")),this.a=null),c=Qb(d.keys[0].k),d=Qb(d.keys[0].kid)):(c=new Uint8Array(b),d=null);try{this.f.webkitAddKey(this.c,c,d,this.sessionId)}catch(e){this.a.reject(e),this.a=null}}}; function lc(a,b){a.keyStatuses.Ba(b);a.dispatchEvent(new F("keystatuseschange"))}k.generateRequest=function(a,b){return nc(this,b,null)};k.load=function(a){return"persistent-license"==this.g?nc(this,null,a):Promise.reject(Error("Not a persistent session."))};k.update=function(a){var b=new O;this.Da(b,a);return b}; k.close=function(){if("persistent-license"!=this.g){if(!this.sessionId)return this.closed.reject(Error("The session is not callable.")),this.closed;this.f.webkitCancelKeyRequest(this.c,this.sessionId)}this.closed.resolve();return this.closed};k.remove=function(){return"persistent-license"!=this.g?Promise.reject(Error("Not a persistent session.")):this.close()};function mc(){this.size=0;this.a=void 0}var oc;k=mc.prototype;k.Ba=function(a){this.size=void 0==a?0:1;this.a=a};k.wa=function(){return this.a}; k.forEach=function(a){this.a&&a(oc,this.a)};k.get=function(a){if(this.has(a))return this.a};k.has=function(a){var b=oc;return this.a&&E(new Uint8Array(a),new Uint8Array(b))?!0:!1};function pc(a){this.systemIds=[];this.cencKeyIds=[];this.a=[];for(a=new Oa(new DataView(a.buffer));Qa(a);){var b=a.a,c=A(a),d=A(a);1==c?c=Ua(a):0==c&&(c=a.b.byteLength-b);if(1886614376!=d)B(a,c-(a.a-b));else{var e=Ra(a);if(1<e)B(a,c-(a.a-b));else{B(a,3);var d=Sb(Va(a)),f=[];if(0<e)for(var e=A(a),g=0;g<e;++g){var h=Sb(Va(a));f.push(h)}e=A(a);B(a,e);this.cencKeyIds.push.apply(this.cencKeyIds,f);this.systemIds.push(d);this.a.push({start:b,end:a.a-1});a.a!=b+c&&B(a,c-(a.a-b))}}}};function qc(a,b){try{var c=new rc(a,b);return Promise.resolve(c)}catch(d){return Promise.reject(d)}} function rc(a,b){this.keySystem=a;for(var c=!1,d=0;d<b.length;++d){var e=b[d],f={audioCapabilities:[],videoCapabilities:[],persistentState:"optional",distinctiveIdentifier:"optional",initDataTypes:e.initDataTypes,sessionTypes:["temporary"],label:e.label},g=!1;if(e.audioCapabilities)for(var h=0;h<e.audioCapabilities.length;++h){var l=e.audioCapabilities[h];if(l.contentType){var g=!0,n=l.contentType.split(";")[0];MSMediaKeys.isTypeSupported(this.keySystem,n)&&(f.audioCapabilities.push(l),c=!0)}}if(e.videoCapabilities)for(h= 0;h<e.videoCapabilities.length;++h)l=e.videoCapabilities[h],l.contentType&&(g=!0,n=l.contentType.split(";")[0],MSMediaKeys.isTypeSupported(this.keySystem,n)&&(f.videoCapabilities.push(l),c=!0));g||(c=MSMediaKeys.isTypeSupported(this.keySystem,"video/mp4"));"required"==e.persistentState&&(f.persistentState="required",f.sessionTypes=["persistent-license"]);if(c){this.a=f;return}}c=Error("Unsupported keySystem");c.name="NotSupportedError";c.code=DOMException.NOT_SUPPORTED_ERR;throw c;} rc.prototype.createMediaKeys=function(){var a=new sc(this.keySystem);return Promise.resolve(a)};rc.prototype.getConfiguration=function(){return this.a};function tc(a){var b=this.mediaKeys;b&&b!=a&&uc(b,null);delete this.mediaKeys;return(this.mediaKeys=a)?uc(a,this):Promise.resolve()}function sc(a){this.a=new MSMediaKeys(a);this.b=new M}sc.prototype.createSession=function(a){if("temporary"!=(a||"temporary"))throw new TypeError("Session type "+a+" is unsupported on this platform.");return new vc(this.a)}; sc.prototype.setServerCertificate=function(){return Promise.reject(Error("setServerCertificate not supported on this platform."))};function uc(a,b){function c(){b.msSetMediaKeys(d.a);b.removeEventListener("loadedmetadata",c)}ob(a.b);if(!b)return Promise.resolve();N(a.b,b,"msneedkey",wc);var d=a;try{return 1<=b.readyState?b.msSetMediaKeys(a.a):b.addEventListener("loadedmetadata",c),Promise.resolve()}catch(e){return Promise.reject(e)}} function vc(a){this.v=new L;this.c=null;this.g=a;this.b=this.a=null;this.f=new M;this.sessionId="";this.expiration=NaN;this.closed=new O;this.keyStatuses=new xc}ba(vc);k=vc.prototype;k.generateRequest=function(a,b){this.a=new O;try{this.c=this.g.createSession("video/mp4",new Uint8Array(b),null),N(this.f,this.c,"mskeymessage",this.$a.bind(this)),N(this.f,this.c,"mskeyadded",this.Ya.bind(this)),N(this.f,this.c,"mskeyerror",this.Za.bind(this)),yc(this,"status-pending")}catch(c){this.a.reject(c)}return this.a}; k.load=function(){return Promise.reject(Error("MediaKeySession.load not yet supported"))};k.update=function(a){this.b=new O;try{this.c.update(new Uint8Array(a))}catch(b){this.b.reject(b)}return this.b};k.close=function(){try{this.c.close(),this.closed.resolve(),ob(this.f)}catch(a){this.closed.reject(a)}return this.closed};k.remove=function(){return Promise.reject(Error("MediaKeySession.remove is only applicable for persistent licenses, which are not supported on this platform"))}; function wc(a){var b=document.createEvent("CustomEvent");b.initCustomEvent("encrypted",!1,!1,null);b.initDataType="cenc";if(a=a.initData){var c=new pc(a);if(!(1>=c.a.length)){for(var d=[],e=0;e<c.a.length;e++)d.push(a.subarray(c.a[e].start,c.a[e].end+1));e=zc;a=[];for(c=0;c<d.length;++c){for(var f=!1,g=0;g<a.length&&!(f=e?e(d[c],a[g]):d[c]===a[g]);++g);f||a.push(d[c])}for(e=d=0;e<a.length;e++)d+=a[e].length;d=new Uint8Array(d);for(e=c=0;e<a.length;e++)d.set(a[e],c),c+=a[e].length;a=d}}b.initData= a;this.dispatchEvent(b)}function zc(a,b){return E(a,b)}k.$a=function(a){this.a&&(this.a.resolve(),this.a=null);this.dispatchEvent(new F("message",{messageType:void 0==this.keyStatuses.wa()?"licenserequest":"licenserenewal",message:a.message.buffer}))};k.Ya=function(){this.a?(yc(this,"usable"),this.a.resolve(),this.a=null):this.b&&(yc(this,"usable"),this.b.resolve(),this.b=null)}; k.Za=function(){var a=Error("EME v20140218 key error");a.errorCode=this.c.error;if(null!=this.a)this.a.reject(a),this.a=null;else if(null!=this.b)this.b.reject(a),this.b=null;else switch(this.c.error.code){case MSMediaKeyError.MS_MEDIA_KEYERR_OUTPUT:case MSMediaKeyError.MS_MEDIA_KEYERR_HARDWARECHANGE:yc(this,"output-not-allowed");default:yc(this,"internal-error")}};function yc(a,b){a.keyStatuses.Ba(b);a.dispatchEvent(new F("keystatuseschange"))}function xc(){this.size=0;this.a=void 0}var Ac;k=xc.prototype; k.Ba=function(a){this.size=void 0==a?0:1;this.a=a};k.wa=function(){return this.a};k.forEach=function(a){this.a&&a(Ac,this.a)};k.get=function(a){if(this.has(a))return this.a};k.has=function(a){var b=Ac;return this.a&&E(new Uint8Array(a),new Uint8Array(b))?!0:!1};ta(function(){!window.HTMLVideoElement||navigator.requestMediaKeySystemAccess&&MediaKeySystemAccess.prototype.getConfiguration||(HTMLMediaElement.prototype.webkitGenerateKeyRequest?(oc=(new Uint8Array([0])).buffer,navigator.requestMediaKeySystemAccess=ec,delete HTMLMediaElement.prototype.mediaKeys,HTMLMediaElement.prototype.mediaKeys=null,HTMLMediaElement.prototype.setMediaKeys=gc,window.MediaKeys=ic,window.MediaKeySystemAccess=fc):window.MSMediaKeys?(Ac=(new Uint8Array([0])).buffer,delete HTMLMediaElement.prototype.mediaKeys, HTMLMediaElement.prototype.mediaKeys=null,HTMLMediaElement.prototype.setMediaKeys=tc,window.MediaKeys=sc,window.MediaKeySystemAccess=rc,navigator.requestMediaKeySystemAccess=qc):(navigator.requestMediaKeySystemAccess=va,delete HTMLMediaElement.prototype.mediaKeys,HTMLMediaElement.prototype.mediaKeys=null,HTMLMediaElement.prototype.setMediaKeys=wa,window.MediaKeys=xa,window.MediaKeySystemAccess=za))});function Bc(a,b){var c=Q(a,b);return 1!=c.length?null:c[0]}function Q(a,b){return Array.prototype.filter.call(a.childNodes,function(a){return a.tagName==b})}function Dc(a){return(a=a.firstChild)&&a.nodeType==Node.TEXT_NODE?a.nodeValue.trim():null}function R(a,b,c,d){var e=null;a=a.getAttribute(b);null!=a&&(e=c(a));return null==e?void 0!==d?d:null:e}function Ec(a){if(!a)return null;a=Date.parse(a);return isNaN(a)?null:Math.floor(a/1E3)} function S(a){if(!a)return null;a=/^P(?:([0-9]*)Y)?(?:([0-9]*)M)?(?:([0-9]*)D)?(?:T(?:([0-9]*)H)?(?:([0-9]*)M)?(?:([0-9.]*)S)?)?$/.exec(a);if(!a)return null;a=31536E3*Number(a[1]||null)+2592E3*Number(a[2]||null)+86400*Number(a[3]||null)+3600*Number(a[4]||null)+60*Number(a[5]||null)+Number(a[6]||null);return isFinite(a)?a:null}function Gc(a){var b=/([0-9]+)-([0-9]+)/.exec(a);if(!b)return null;a=Number(b[1]);if(!isFinite(a))return null;b=Number(b[2]);return isFinite(b)?{start:a,end:b}:null} function Hc(a){a=Number(a);return 0===a%1?a:null}function Ic(a){a=Number(a);return 0===a%1&&0<a?a:null}function Jc(a){a=Number(a);return 0===a%1&&0<=a?a:null};var Kc={"urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b":"org.w3.clearkey","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed":"com.widevine.alpha","urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95":"com.microsoft.playready","urn:uuid:f239e769-efa3-4850-9c16-a903c6932efb":"com.adobe.primetime"}; function Lc(a,b){var c=Mc(a),d=null,e=c.filter(function(a){return"urn:mpeg:dash:mp4protection:2011"==a.Ia?(d=a.init||d,!1):!0}),f=c.map(function(a){return a.keyId}).filter(H),g=null;if(0<f.length&&(g=f[0],f.some(bb(g))))throw new x(4,4010);f=[];0<e.length?(f=Nc(d,b,e),0==f.length&&(f=[Oc("",d)])):0<c.length&&(f=K(Kc).map(function(a){return Oc(a,d)}));return{Fa:g,Hb:d,drmInfos:f,Ga:!0}} function Pc(a,b,c){var d=Lc(a,b);if(c.Ga){a=1==c.drmInfos.length&&!c.drmInfos[0].keySystem;b=0==d.drmInfos.length;if(0==c.drmInfos.length||a&&!b)c.drmInfos=d.drmInfos;c.Ga=!1}else if(0<d.drmInfos.length&&(c.drmInfos=c.drmInfos.filter(function(a){return d.drmInfos.some(function(b){return b.keySystem==a.keySystem})}),0==c.drmInfos.length))throw new x(4,4008);return d.Fa||c.Fa} function Oc(a,b){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:b||[]}}function Nc(a,b,c){return c.map(function(c){var e=Kc[c.Ia];return e?[Oc(e,c.init||a)]:b(c.node)||[]}).reduce(ab,[])} function Mc(a){return a.map(function(a){var c=a.getAttribute("schemeIdUri"),d=a.getAttribute("cenc:default_KID"),e=Q(a,"cenc:pssh").map(Dc);if(!c)return null;c=c.toLowerCase();if(d&&(d=d.replace(/-/g,"").toLowerCase(),0<=d.indexOf(" ")))throw new x(4,4009);var f=[];try{f=e.map(function(a){return{initDataType:"cenc",initData:Qb(a)}})}catch(g){throw new x(4,4007);}return{node:a,Ia:c,keyId:d,init:0<f.length?f:null}}).filter(H)};var Qc=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#(.*))?$/;function T(a){var b;a instanceof T?(Rc(this,a.I),this.Z=a.Z,this.K=a.K,Sc(this,a.ca),this.F=a.F,Tc(this,Uc(a.a)),this.V=a.V):a&&(b=String(a).match(Qc))?(Rc(this,b[1]||"",!0),this.Z=Vc(b[2]||""),this.K=Vc(b[3]||"",!0),Sc(this,b[4]),this.F=Vc(b[5]||"",!0),Tc(this,b[6]||"",!0),this.V=Vc(b[7]||"")):this.a=new U(null)}k=T.prototype;k.I="";k.Z="";k.K="";k.ca=null;k.F="";k.V=""; k.toString=function(){var a=[],b=this.I;b&&a.push(Wc(b,Xc,!0),":");if(b=this.K){a.push("//");var c=this.Z;c&&a.push(Wc(c,Xc,!0),"@");a.push(encodeURIComponent(b).replace(/%25([0-9a-fA-F]{2})/g,"%$1"));b=this.ca;null!=b&&a.push(":",String(b))}if(b=this.F)this.K&&"/"!=b.charAt(0)&&a.push("/"),a.push(Wc(b,"/"==b.charAt(0)?Yc:Zc,!0));(b=this.a.toString())&&a.push("?",b);(b=this.V)&&a.push("#",Wc(b,$c));return a.join("")}; k.resolve=function(a){var b=new T(this);"data"===b.I&&(b=new T);var c=!!a.I;c?Rc(b,a.I):c=!!a.Z;c?b.Z=a.Z:c=!!a.K;c?b.K=a.K:c=null!=a.ca;var d=a.F;if(c)Sc(b,a.ca);else if(c=!!a.F){if("/"!=d.charAt(0))if(this.K&&!this.F)d="/"+d;else{var e=b.F.lastIndexOf("/");-1!=e&&(d=b.F.substr(0,e+1)+d)}if(".."==d||"."==d)d="";else if(-1!=d.indexOf("./")||-1!=d.indexOf("/.")){for(var e=0==d.lastIndexOf("/",0),d=d.split("/"),f=[],g=0;g<d.length;){var h=d[g++];"."==h?e&&g==d.length&&f.push(""):".."==h?((1<f.length|| 1==f.length&&""!=f[0])&&f.pop(),e&&g==d.length&&f.push("")):(f.push(h),e=!0)}d=f.join("/")}}c?b.F=d:c=""!==a.a.toString();c?Tc(b,Uc(a.a)):c=!!a.V;c&&(b.V=a.V);return b};function Rc(a,b,c){a.I=c?Vc(b,!0):b;a.I&&(a.I=a.I.replace(/:$/,""))}function Sc(a,b){if(b){b=Number(b);if(isNaN(b)||0>b)throw Error("Bad port number "+b);a.ca=b}else a.ca=null}function ad(a){return a.F}function Tc(a,b,c){b instanceof U?a.a=b:(c||(b=Wc(b,bd)),a.a=new U(b))} function Vc(a,b){return a?b?decodeURI(a):decodeURIComponent(a):""}function Wc(a,b,c){return"string"==typeof a?(a=encodeURI(a).replace(b,cd),c&&(a=a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),a):null}function cd(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)}var Xc=/[#\/\?@]/g,Zc=/[\#\?:]/g,Yc=/[\#\?]/g,bd=/[\#\?@]/g,$c=/#/g;function U(a){this.b=a||null}U.prototype.a=null;U.prototype.c=null; U.prototype.toString=function(){if(this.b)return this.b;if(!this.a)return"";var a=[],b;for(b in this.a)for(var c=encodeURIComponent(b),d=this.a[b],e=0;e<d.length;e++){var f=c;""!==d[e]&&(f+="="+encodeURIComponent(d[e]));a.push(f)}return this.b=a.join("&")};function Uc(a){var b=new U;b.b=a.b;if(a.a){var c={},d;for(d in a.a)c[d]=a.a[d].concat();b.a=c;b.c=a.c}return b};var dd=1/15;function ed(a,b,c,d,e){null!==e&&(e=Math.round(e));var f={RepresentationID:b,Number:c,Bandwidth:d,Time:e};return a.replace(/\$(RepresentationID|Number|Bandwidth|Time)?(?:%0([0-9]+)d)?\$/g,function(a,b,c){if("$$"==a)return"$";var d=f[b];if(null==d)return a;"RepresentationID"==b&&c&&(c=void 0);a=d.toString();c=window.parseInt(c,10)||1;return Array(Math.max(0,c-a.length)+1).join("0")+a})} function fd(a,b){if(0!=b.length){var c=b[0];c.startTime<=dd&&(b[0]=new v(c.position,0,c.a,c.uris,c.c,c.b));null!=a&&a!=Number.POSITIVE_INFINITY&&(c=b[b.length-1],c.startTime>a||(b[b.length-