UNPKG

shaka-player

Version:
116 lines (112 loc) 398 kB
var COMPILED=!0,goog=goog||{};goog.global=this;goog.isDef=function(a){return void 0!==a};goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]?c[d]:c[d]={}}; goog.define=function(a,b){var c=b;COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,a)?c=goog.global.CLOSURE_UNCOMPILED_DEFINES[a]:goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]));goog.exportPath_(a,c)};goog.DEBUG=!0;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.STRICT_MODE_COMPATIBLE=!0; goog.provide=function(a){if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a];for(var b=a;(b=b.substring(0,b.lastIndexOf(".")))&&!goog.getObjectByName(b);)goog.implicitNamespaces_[b]=!0}goog.exportPath_(a)};goog.forwardDeclare=function(a){};COMPILED||(goog.isProvided_=function(a){return!goog.implicitNamespaces_[a]&&goog.isDefAndNotNull(goog.getObjectByName(a))},goog.implicitNamespaces_={}); goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};goog.addDependency=function(a,b,c){if(goog.DEPENDENCIES_ENABLED){var d;a=a.replace(/\\/g,"/");for(var e=goog.dependencies_,f=0;d=b[f];f++)e.nameToPath[d]=a;for(d=0;b=c[d];d++)a in e.requires||(e.requires[a]={}),e.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!1; goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)};goog.require=function(a){if(!COMPILED){if(goog.isProvided_(a))return null;if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b)return goog.included_[b]=!0,goog.writeScripts_(),null}a="goog.require could not find: "+a;goog.logToConsole_(a);throw Error(a);}};goog.basePath="";goog.global.CLOSURE_NO_DEPS=!0;goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER; goog.DEPENDENCIES_ENABLED&&(goog.included_={},goog.dependencies_={nameToPath:{},requires:{},visited:{},written:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return"undefined"!=typeof a&&"write"in a},goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH)goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("script"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length:d;if("base.js"== c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a,b){(goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_)(a,b)&&(goog.dependencies_.written[a]=!0)},goog.writeScriptTag_=function(a,b){if(goog.inHtmlDocument_()){var c=goog.global.document;if("complete"==c.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}void 0===b?c.write('<script type="text/javascript" src="'+a+'">\x3c/script>'):c.write('<script type="text/javascript">'+ b+"\x3c/script>");return!0}return!1},goog.writeScripts_=function(){function a(e){if(!(e in d.written)){if(!(e in d.visited)&&(d.visited[e]=!0,e in d.requires))for(var f in d.requires[e])if(!goog.isProvided_(f))if(f in d.nameToPath)a(d.nameToPath[f]);else throw Error("Undefined nameToPath for "+f);e in c||(c[e]=!0,b.push(e))}}var b=[],c={},d=goog.dependencies_;for(f in goog.included_)d.written[f]||a(f);for(var e=0;e<b.length;e++){var f=b[e];goog.dependencies_.written[f]=!0}for(e=0;e<b.length;e++)(f= b[e])&&goog.importScript_(goog.basePath+f)},goog.getPathFromDeps_=function(a){return a in goog.dependencies_.nameToPath?goog.dependencies_.nameToPath[a]:null},goog.findBasePath_(),goog.global.CLOSURE_NO_DEPS||goog.importScript_(goog.basePath+"deps.js"));goog.isDefAndNotNull=function(a){return null!=a};goog.isString=function(a){return"string"==typeof a};goog.exportSymbol=function(a,b,c){goog.exportPath_(a,b,c)};goog.exportProperty=function(a,b,c){a[b]=c}; goog.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.base=function(a,c,f){var d=Array.prototype.slice.call(arguments,2);return b.prototype[c].apply(a,d)}};COMPILED||(goog.global.COMPILED=COMPILED);/* 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. */ goog.asserts={};goog.asserts.ENABLE_ASSERTS=!0;goog.asserts.assert=function(){};goog.asserts.patchAssert_=function(){var a=console.assert;a?a.bind||(console.assert=function(){a.apply(console,arguments)}):console.assert=function(){}};goog.asserts.ENABLE_ASSERTS&&(goog.asserts.patchAssert_(),goog.asserts.assert=console.assert.bind(console));var shaka={abr:{}};shaka.abr.Ewma=function(a){goog.asserts.assert(0<a,"expected halfLife to be positive");this.alpha_=Math.exp(Math.log(.5)/a);this.totalWeight_=this.estimate_=0};shaka.abr.Ewma.prototype.sample=function(a,b){var c=Math.pow(this.alpha_,a),c=b*(1-c)+c*this.estimate_;isNaN(c)||(this.estimate_=c,this.totalWeight_+=a)};shaka.abr.Ewma.prototype.getEstimate=function(){return this.estimate_/(1-Math.pow(this.alpha_,this.totalWeight_))};shaka.abr.EwmaBandwidthEstimator=function(){this.fast_=new shaka.abr.Ewma(2);this.slow_=new shaka.abr.Ewma(5);this.bytesSampled_=0;this.minTotalBytes_=128E3;this.minBytes_=16E3};shaka.abr.EwmaBandwidthEstimator.prototype.sample=function(a,b){if(!(b<this.minBytes_)){var c=8E3*b/a,d=a/1E3;this.bytesSampled_+=b;this.fast_.sample(d,c);this.slow_.sample(d,c)}}; shaka.abr.EwmaBandwidthEstimator.prototype.getBandwidthEstimate=function(a){return this.bytesSampled_<this.minTotalBytes_?a:Math.min(this.fast_.getEstimate(),this.slow_.getEstimate())};shaka.abr.EwmaBandwidthEstimator.prototype.hasGoodEstimate=function(){return this.bytesSampled_>=this.minTotalBytes_};shaka.log={};shaka.log.Level={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4,V1:5,V2:6};shaka.log.MAX_LOG_LEVEL=4;shaka.log.alwaysWarn=function(){};shaka.log.error=function(){};shaka.log.warning=function(){};shaka.log.info=function(){};shaka.log.debug=function(){};shaka.log.v1=function(){};shaka.log.v2=function(){}; window.console&&window.console.log.bind&&(shaka.log.alwaysWarn=console.warn.bind(console),goog.DEBUG?(shaka.log.setLevel=function(a){var b=function(){},c=shaka.log,d=shaka.log.Level;shaka.log.currentLevel=a;c.error=a>=d.ERROR?console.error.bind(console):b;c.warning=a>=d.WARNING?console.warn.bind(console):b;c.info=a>=d.INFO?console.info.bind(console):b;c.debug=a>=d.DEBUG?console.log.bind(console):b;c.v1=a>=d.V1?console.debug.bind(console):b;c.v2=a>=d.V2?console.debug.bind(console):b},shaka.log.setLevel(shaka.log.MAX_LOG_LEVEL)): (shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.ERROR&&(shaka.log.error=console.error.bind(console)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.WARNING&&(shaka.log.warning=console.warn.bind(console)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.INFO&&(shaka.log.info=console.info.bind(console)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.DEBUG&&(shaka.log.debug=console.log.bind(console)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.V1&&(shaka.log.v1=console.debug.bind(console)),shaka.log.MAX_LOG_LEVEL>=shaka.log.Level.V2&& (shaka.log.v2=console.debug.bind(console))));shaka.util={};shaka.util.Error=function(a,b,c,d){this.severity=a;this.category=b;this.code=c;this.data=Array.prototype.slice.call(arguments,3);this.handled=!1;if(goog.DEBUG){var e="UNKNOWN",f="UNKNOWN",g;for(g in shaka.util.Error.Category)shaka.util.Error.Category[g]==this.category&&(e=g);for(g in shaka.util.Error.Code)shaka.util.Error.Code[g]==this.code&&(f=g);this.message="Shaka Error "+e+"."+f+" ("+this.data.toString()+")";try{throw Error(this.message);}catch(h){this.stack=h.stack}}}; goog.exportSymbol("shaka.util.Error",shaka.util.Error);shaka.util.Error.prototype.toString=function(){return"shaka.util.Error "+JSON.stringify(this,null," ")};shaka.util.Error.Severity={RECOVERABLE:1,CRITICAL:2};goog.exportProperty(shaka.util.Error,"Severity",shaka.util.Error.Severity);shaka.util.Error.Category={NETWORK:1,TEXT:2,MEDIA:3,MANIFEST:4,STREAMING:5,DRM:6,PLAYER:7,CAST:8,STORAGE:9};goog.exportProperty(shaka.util.Error,"Category",shaka.util.Error.Category); shaka.util.Error.Code={UNSUPPORTED_SCHEME:1E3,BAD_HTTP_STATUS:1001,HTTP_ERROR:1002,TIMEOUT:1003,MALFORMED_DATA_URI:1004,UNKNOWN_DATA_URI_ENCODING:1005,REQUEST_FILTER_ERROR:1006,RESPONSE_FILTER_ERROR:1007,INVALID_TEXT_HEADER:2E3,INVALID_TEXT_CUE:2001,UNABLE_TO_DETECT_ENCODING:2003,BAD_ENCODING:2004,INVALID_XML:2005,INVALID_MP4_TTML:2007,INVALID_MP4_VTT:2008,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,QUOTA_EXCEEDED_ERROR:3017,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,RESTRICTIONS_CANNOT_BE_MET:4012,NO_PERIODS:4014,HLS_PLAYLIST_HEADER_MISSING:4015,INVALID_HLS_TAG:4016,HLS_INVALID_PLAYLIST_HIERARCHY:4017,DASH_DUPLICATE_REPRESENTATION_ID:4018,HLS_MULTIPLE_MEDIA_INIT_SECTIONS_FOUND:4020,HLS_COULD_NOT_GUESS_MIME_TYPE:4021,HLS_MASTER_PLAYLIST_NOT_PROVIDED:4022, HLS_REQUIRED_ATTRIBUTE_MISSING:4023,HLS_REQUIRED_TAG_MISSING:4024,HLS_COULD_NOT_GUESS_CODECS:4025,HLS_KEYFORMATS_NOT_SUPPORTED:4026,DASH_UNSUPPORTED_XLINK_ACTUATE:4027,DASH_XLINK_DEPTH_LIMIT:4028,HLS_LIVE_CONTENT_NOT_SUPPORTED:4029,INVALID_STREAMS_CHOSEN:5005,NO_RECOGNIZED_KEY_SYSTEMS:6E3,REQUESTED_KEY_SYSTEM_CONFIG_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,NO_LICENSE_SERVER_GIVEN:6012,OFFLINE_SESSION_REMOVED:6013,EXPIRED:6014,LOAD_INTERRUPTED:7E3,CAST_API_UNAVAILABLE:8E3,NO_CAST_RECEIVERS:8001,ALREADY_CASTING:8002,UNEXPECTED_CAST_ERROR:8003,CAST_CANCELED_BY_USER:8004,CAST_CONNECTION_TIMED_OUT:8005,CAST_RECEIVER_APP_UNAVAILABLE:8006,STORAGE_NOT_SUPPORTED:9E3,INDEXED_DB_ERROR:9001,OPERATION_ABORTED:9002,REQUESTED_ITEM_NOT_FOUND:9003,MALFORMED_OFFLINE_URI:9004,CANNOT_STORE_LIVE_OFFLINE:9005, STORE_ALREADY_IN_PROGRESS:9006,NO_INIT_DATA_FOR_OFFLINE:9007,LOCAL_PLAYER_INSTANCE_REQUIRED:9008,CONTENT_UNSUPPORTED_BY_BROWSER:9009};goog.exportProperty(shaka.util.Error,"Code",shaka.util.Error.Code);goog.uri={};goog.uri.utils={};goog.uri.utils.splitRe_=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#(.*))?$/;goog.uri.utils.ComponentIndex={SCHEME:1,USER_INFO:2,DOMAIN:3,PORT:4,PATH:5,QUERY_DATA:6,FRAGMENT:7};goog.uri.utils.split=function(a){return a.match(goog.uri.utils.splitRe_)};goog.Uri=function(a){var b;a instanceof goog.Uri?(this.setScheme(a.getScheme()),this.setUserInfo(a.getUserInfo()),this.setDomain(a.getDomain()),this.setPort(a.getPort()),this.setPath(a.getPath()),this.setQueryData(a.getQueryData().clone()),this.setFragment(a.getFragment())):a&&(b=goog.uri.utils.split(String(a)))?(this.setScheme(b[goog.uri.utils.ComponentIndex.SCHEME]||"",!0),this.setUserInfo(b[goog.uri.utils.ComponentIndex.USER_INFO]||"",!0),this.setDomain(b[goog.uri.utils.ComponentIndex.DOMAIN]|| "",!0),this.setPort(b[goog.uri.utils.ComponentIndex.PORT]),this.setPath(b[goog.uri.utils.ComponentIndex.PATH]||"",!0),this.setQueryData(b[goog.uri.utils.ComponentIndex.QUERY_DATA]||"",!0),this.setFragment(b[goog.uri.utils.ComponentIndex.FRAGMENT]||"",!0)):this.queryData_=new goog.Uri.QueryData(null,null)};goog.Uri.prototype.scheme_="";goog.Uri.prototype.userInfo_="";goog.Uri.prototype.domain_="";goog.Uri.prototype.port_=null;goog.Uri.prototype.path_="";goog.Uri.prototype.fragment_=""; goog.Uri.prototype.toString=function(){var a=[],b=this.getScheme();b&&a.push(goog.Uri.encodeSpecialChars_(b,goog.Uri.reDisallowedInSchemeOrUserInfo_,!0),":");if(b=this.getDomain()){a.push("//");var c=this.getUserInfo();c&&a.push(goog.Uri.encodeSpecialChars_(c,goog.Uri.reDisallowedInSchemeOrUserInfo_,!0),"@");a.push(goog.Uri.removeDoubleEncoding_(encodeURIComponent(b)));b=this.getPort();null!=b&&a.push(":",String(b))}if(b=this.getPath())this.hasDomain()&&"/"!=b.charAt(0)&&a.push("/"),a.push(goog.Uri.encodeSpecialChars_(b, "/"==b.charAt(0)?goog.Uri.reDisallowedInAbsolutePath_:goog.Uri.reDisallowedInRelativePath_,!0));(b=this.getEncodedQuery())&&a.push("?",b);(b=this.getFragment())&&a.push("#",goog.Uri.encodeSpecialChars_(b,goog.Uri.reDisallowedInFragment_));return a.join("")}; goog.Uri.prototype.resolve=function(a){var b=this.clone();"data"===b.scheme_&&(b=new goog.Uri);var c=a.hasScheme();c?b.setScheme(a.getScheme()):c=a.hasUserInfo();c?b.setUserInfo(a.getUserInfo()):c=a.hasDomain();c?b.setDomain(a.getDomain()):c=a.hasPort();var d=a.getPath();if(c)b.setPort(a.getPort());else if(c=a.hasPath()){if("/"!=d.charAt(0))if(this.hasDomain()&&!this.hasPath())d="/"+d;else{var e=b.getPath().lastIndexOf("/");-1!=e&&(d=b.getPath().substr(0,e+1)+d)}d=goog.Uri.removeDotSegments(d)}c? b.setPath(d):c=a.hasQuery();c?b.setQueryData(a.getQueryData().clone()):c=a.hasFragment();c&&b.setFragment(a.getFragment());return b};goog.Uri.prototype.clone=function(){return new goog.Uri(this)};goog.Uri.prototype.getScheme=function(){return this.scheme_};goog.Uri.prototype.setScheme=function(a,b){if(this.scheme_=b?goog.Uri.decodeOrEmpty_(a,!0):a)this.scheme_=this.scheme_.replace(/:$/,"");return this};goog.Uri.prototype.hasScheme=function(){return!!this.scheme_};goog.Uri.prototype.getUserInfo=function(){return this.userInfo_}; goog.Uri.prototype.setUserInfo=function(a,b){this.userInfo_=b?goog.Uri.decodeOrEmpty_(a):a;return this};goog.Uri.prototype.hasUserInfo=function(){return!!this.userInfo_};goog.Uri.prototype.getDomain=function(){return this.domain_};goog.Uri.prototype.setDomain=function(a,b){this.domain_=b?goog.Uri.decodeOrEmpty_(a,!0):a;return this};goog.Uri.prototype.hasDomain=function(){return!!this.domain_};goog.Uri.prototype.getPort=function(){return this.port_}; goog.Uri.prototype.setPort=function(a){if(a){a=Number(a);if(isNaN(a)||0>a)throw Error("Bad port number "+a);this.port_=a}else this.port_=null;return this};goog.Uri.prototype.hasPort=function(){return null!=this.port_};goog.Uri.prototype.getPath=function(){return this.path_};goog.Uri.prototype.setPath=function(a,b){this.path_=b?goog.Uri.decodeOrEmpty_(a,!0):a;return this};goog.Uri.prototype.hasPath=function(){return!!this.path_};goog.Uri.prototype.hasQuery=function(){return""!==this.queryData_.toString()}; goog.Uri.prototype.setQueryData=function(a,b){a instanceof goog.Uri.QueryData?this.queryData_=a:(b||(a=goog.Uri.encodeSpecialChars_(a,goog.Uri.reDisallowedInQuery_)),this.queryData_=new goog.Uri.QueryData(a,null));return this};goog.Uri.prototype.getEncodedQuery=function(){return this.queryData_.toString()};goog.Uri.prototype.getDecodedQuery=function(){return this.queryData_.toDecodedString()};goog.Uri.prototype.getQueryData=function(){return this.queryData_};goog.Uri.prototype.getFragment=function(){return this.fragment_}; goog.Uri.prototype.setFragment=function(a,b){this.fragment_=b?goog.Uri.decodeOrEmpty_(a):a;return this};goog.Uri.prototype.hasFragment=function(){return!!this.fragment_}; goog.Uri.removeDotSegments=function(a){if(".."==a||"."==a)return"";if(-1==a.indexOf("./")&&-1==a.indexOf("/."))return a;var b=0==a.lastIndexOf("/",0);a=a.split("/");for(var c=[],d=0;d<a.length;){var e=a[d++];"."==e?b&&d==a.length&&c.push(""):".."==e?((1<c.length||1==c.length&&""!=c[0])&&c.pop(),b&&d==a.length&&c.push("")):(c.push(e),b=!0)}return c.join("/")};goog.Uri.decodeOrEmpty_=function(a,b){return a?b?decodeURI(a):decodeURIComponent(a):""}; goog.Uri.encodeSpecialChars_=function(a,b,c){return goog.isString(a)?(a=encodeURI(a).replace(b,goog.Uri.encodeChar_),c&&(a=goog.Uri.removeDoubleEncoding_(a)),a):null};goog.Uri.encodeChar_=function(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)};goog.Uri.removeDoubleEncoding_=function(a){return a.replace(/%25([0-9a-fA-F]{2})/g,"%$1")};goog.Uri.reDisallowedInSchemeOrUserInfo_=/[#\/\?@]/g;goog.Uri.reDisallowedInRelativePath_=/[\#\?:]/g; goog.Uri.reDisallowedInAbsolutePath_=/[\#\?]/g;goog.Uri.reDisallowedInQuery_=/[\#\?@]/g;goog.Uri.reDisallowedInFragment_=/#/g;goog.Uri.QueryData=function(a,b){this.encodedQuery_=a||null}; goog.Uri.QueryData.prototype.ensureKeyMapInitialized_=function(){if(!this.keyMap_&&(this.keyMap_={},this.count_=0,this.encodedQuery_))for(var a=this.encodedQuery_.split("&"),b=0;b<a.length;b++){var c=a[b].indexOf("="),d=null;if(0<=c){var e=a[b].substring(0,c);d=a[b].substring(c+1)}else e=a[b];e=decodeURIComponent(e.replace(/\+/g," "));d=d||"";this.add(e,decodeURIComponent(d.replace(/\+/g," ")))}};goog.Uri.QueryData.prototype.keyMap_=null;goog.Uri.QueryData.prototype.count_=null; goog.Uri.QueryData.prototype.getCount=function(){this.ensureKeyMapInitialized_();return this.count_};goog.Uri.QueryData.prototype.add=function(a,b){this.ensureKeyMapInitialized_();this.encodedQuery_=null;var c=this.keyMap_.hasOwnProperty(a)&&this.keyMap_[a];c||(this.keyMap_[a]=c=[]);c.push(b);this.count_++;return this}; goog.Uri.QueryData.prototype.toString=function(){if(this.encodedQuery_)return this.encodedQuery_;if(!this.keyMap_)return"";var a=[],b;for(b in this.keyMap_)for(var c=encodeURIComponent(b),d=this.keyMap_[b],e=0;e<d.length;e++){var f=c;""!==d[e]&&(f+="="+encodeURIComponent(d[e]));a.push(f)}return this.encodedQuery_=a.join("&")};goog.Uri.QueryData.prototype.toDecodedString=function(){return goog.Uri.decodeOrEmpty_(this.toString())}; goog.Uri.QueryData.prototype.clone=function(){var a=new goog.Uri.QueryData;a.encodedQuery_=this.encodedQuery_;if(this.keyMap_){var b={},c;for(c in this.keyMap_)b[c]=this.keyMap_[c].concat();a.keyMap_=b;a.count_=this.count_}return a};shaka.util.PublicPromise=function(){var a,b,c=new Promise(function(c,e){a=c;b=e});c.resolve=a;c.reject=b;return c};shaka.net={}; shaka.net.Backoff=function(a,b,c){var d=shaka.net.Backoff.defaultRetryParameters();this.maxAttempts_=null==a.maxAttempts?d.maxAttempts:a.maxAttempts;goog.asserts.assert(1<=this.maxAttempts_,"maxAttempts should be >= 1");this.baseDelay_=null==a.baseDelay?d.baseDelay:a.baseDelay;goog.asserts.assert(0<=this.baseDelay_,"baseDelay should be >= 0");this.fuzzFactor_=null==a.fuzzFactor?d.fuzzFactor:a.fuzzFactor;goog.asserts.assert(0<=this.fuzzFactor_,"fuzzFactor should be >= 0");this.backoffFactor_=null== a.backoffFactor?d.backoffFactor:a.backoffFactor;goog.asserts.assert(0<=this.backoffFactor_,"backoffFactor should be >= 0");this.numAttempts_=0;this.nextUnfuzzedDelay_=this.baseDelay_;this.autoReset_=b||!1;this.isCanceled_=c||null;this.autoReset_&&(goog.asserts.assert(2<=this.maxAttempts_,"maxAttempts must be >= 2 for autoReset == true"),this.numAttempts_=1)}; shaka.net.Backoff.prototype.attempt=function(){if(this.numAttempts_>=this.maxAttempts_)if(this.autoReset_)this.reset_();else return Promise.reject();var a=new shaka.util.PublicPromise;if(this.numAttempts_){var b=shaka.net.Backoff.fuzz_(this.nextUnfuzzedDelay_,this.fuzzFactor_);this.cancelableTimeout_(a.resolve,b);this.nextUnfuzzedDelay_*=this.backoffFactor_}else goog.asserts.assert(!this.autoReset_,"Failed to delay with auto-reset!"),a.resolve();this.numAttempts_++;return a}; shaka.net.Backoff.defaultRetryParameters=function(){return{maxAttempts:2,baseDelay:1E3,backoffFactor:2,fuzzFactor:.5,timeout:0}};shaka.net.Backoff.fuzz_=function(a,b){return a*(1+(2*Math.random()-1)*b)};shaka.net.Backoff.prototype.reset_=function(){goog.asserts.assert(this.autoReset_,"Should only be used for auto-reset!");this.numAttempts_=1;this.nextUnfuzzedDelay_=this.baseDelay_}; shaka.net.Backoff.prototype.cancelableTimeout_=function(a,b){if(this.isCanceled_)if(this.isCanceled_()||0==b)a();else{var c=Math.min(200,b);shaka.net.Backoff.setTimeout_(function(){this.cancelableTimeout_(a,b-c)}.bind(this),c)}else shaka.net.Backoff.setTimeout_(a,b)};shaka.net.Backoff.setTimeout_=function(a,b){return window.setTimeout(a,b)};shaka.util.ConfigUtils={}; shaka.util.ConfigUtils.mergeConfigObjects=function(a,b,c,d,e){goog.asserts.assert(a,"Destination config must not be null!");var f=e in d,g;for(g in b){var h=e+"."+g,k=f?d[e]:c[g];f||g in a?void 0===b[g]?void 0===k||f?delete a[g]:a[g]=k:k.constructor==Object&&b[g]&&b[g].constructor==Object?(a[g]||(goog.asserts.assert(f,"Null destination without ignoreKeys!"),a[g]=k),shaka.util.ConfigUtils.mergeConfigObjects(a[g],b[g],k,d,h)):typeof b[g]!=typeof k||null==b[g]||b[g].constructor!=k.constructor?shaka.log.error("Invalid config, wrong type for "+ h):("function"==typeof a[g]&&a[g].length!=b[g].length&&shaka.log.warning("Invalid config, wrong number of arguments for "+h),a[g]=b[g]):shaka.log.error("Invalid config, unrecognized key "+h)}}; shaka.util.ConfigUtils.cloneObject=function(a){var b=[],c=function(a){switch(typeof a){case "undefined":case "boolean":case "number":case "string":case "symbol":case "function":return a;default:if(!a)return a;if(0<=b.indexOf(a))return null;var d=a.constructor==Array;if(a.constructor!=Object&&!d)return null;b.push(a);var f=d?[]:{},g;for(g in a)f[g]=c(a[g]);d&&(f.length=a.length);return f}};return c(a)};shaka.util.Functional={};shaka.util.Functional.createFallbackPromiseChain=function(a,b){return a.reduce(function(a,b,e){return b["catch"](a.bind(null,e))}.bind(null,b),Promise.reject())};shaka.util.Functional.collapseArrays=function(a,b){return a.concat(b)};shaka.util.Functional.noop=function(){};shaka.util.Functional.isNotNull=function(a){return null!=a};shaka.util.Functional.isNotDuplicate=function(a,b,c){return c.indexOf(a)==b};shaka.util.IDestroyable=function(){};shaka.util.IDestroyable.prototype.destroy=function(){};shaka.net.NetworkingEngine=function(a){this.destroyed_=!1;this.requests_=[];this.requestFilters_=[];this.responseFilters_=[];this.onSegmentDownloaded_=a||null};goog.exportSymbol("shaka.net.NetworkingEngine",shaka.net.NetworkingEngine);shaka.net.NetworkingEngine.RequestType={MANIFEST:0,SEGMENT:1,LICENSE:2,APP:3};goog.exportProperty(shaka.net.NetworkingEngine,"RequestType",shaka.net.NetworkingEngine.RequestType);shaka.net.NetworkingEngine.schemes_={}; shaka.net.NetworkingEngine.registerScheme=function(a,b){shaka.net.NetworkingEngine.schemes_[a]=b};goog.exportProperty(shaka.net.NetworkingEngine,"registerScheme",shaka.net.NetworkingEngine.registerScheme);shaka.net.NetworkingEngine.unregisterScheme=function(a){delete shaka.net.NetworkingEngine.schemes_[a]};goog.exportProperty(shaka.net.NetworkingEngine,"unregisterScheme",shaka.net.NetworkingEngine.unregisterScheme);shaka.net.NetworkingEngine.prototype.registerRequestFilter=function(a){this.requestFilters_.push(a)}; goog.exportProperty(shaka.net.NetworkingEngine.prototype,"registerRequestFilter",shaka.net.NetworkingEngine.prototype.registerRequestFilter);shaka.net.NetworkingEngine.prototype.unregisterRequestFilter=function(a){var b=this.requestFilters_;a=b.indexOf(a);0<=a&&b.splice(a,1)};goog.exportProperty(shaka.net.NetworkingEngine.prototype,"unregisterRequestFilter",shaka.net.NetworkingEngine.prototype.unregisterRequestFilter); shaka.net.NetworkingEngine.prototype.clearAllRequestFilters=function(){this.requestFilters_=[]};goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearAllRequestFilters",shaka.net.NetworkingEngine.prototype.clearAllRequestFilters);shaka.net.NetworkingEngine.prototype.registerResponseFilter=function(a){this.responseFilters_.push(a)};goog.exportProperty(shaka.net.NetworkingEngine.prototype,"registerResponseFilter",shaka.net.NetworkingEngine.prototype.registerResponseFilter); shaka.net.NetworkingEngine.prototype.unregisterResponseFilter=function(a){var b=this.responseFilters_;a=b.indexOf(a);0<=a&&b.splice(a,1)};goog.exportProperty(shaka.net.NetworkingEngine.prototype,"unregisterResponseFilter",shaka.net.NetworkingEngine.prototype.unregisterResponseFilter);shaka.net.NetworkingEngine.prototype.clearAllResponseFilters=function(){this.responseFilters_=[]};goog.exportProperty(shaka.net.NetworkingEngine.prototype,"clearAllResponseFilters",shaka.net.NetworkingEngine.prototype.clearAllResponseFilters); shaka.net.NetworkingEngine.defaultRetryParameters=shaka.net.Backoff.defaultRetryParameters;shaka.net.NetworkingEngine.makeRequest=function(a,b){return{uris:a,method:"GET",body:null,headers:{},allowCrossSiteCredentials:!1,retryParameters:b}};shaka.net.NetworkingEngine.prototype.destroy=function(){var a=shaka.util.Functional;this.destroyed_=!0;this.requestFilters_=[];this.responseFilters_=[];for(var b=[],c=0;c<this.requests_.length;++c)b.push(this.requests_[c]["catch"](a.noop));return Promise.all(b)}; goog.exportProperty(shaka.net.NetworkingEngine.prototype,"destroy",shaka.net.NetworkingEngine.prototype.destroy); shaka.net.NetworkingEngine.prototype.request=function(a,b,c){var d=c||function(){return!1},e=shaka.util.ConfigUtils.cloneObject;if(this.destroyed_)return Promise.reject();goog.asserts.assert(b.uris&&b.uris.length,"Request without URIs!");b.method=b.method||"GET";b.headers=b.headers||{};b.retryParameters=b.retryParameters?e(b.retryParameters):shaka.net.NetworkingEngine.defaultRetryParameters();b.uris=e(b.uris);var f=Date.now(),g=Promise.resolve();this.requestFilters_.forEach(function(c){g=g.then(c.bind(null, a,b))});g=g["catch"](function(a){throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.REQUEST_FILTER_ERROR,a);});g=g.then(function(){var e=Date.now()-f,g=new shaka.net.Backoff(b.retryParameters,!1,c);return g.attempt().then(function(){return this.send_(a,b,g,0,e,d)}.bind(this))}.bind(this));this.requests_.push(g);return g.then(function(b){0<=this.requests_.indexOf(g)&&this.requests_.splice(this.requests_.indexOf(g),1);if(this.onSegmentDownloaded_&& !b.fromCache&&a==shaka.net.NetworkingEngine.RequestType.SEGMENT)this.onSegmentDownloaded_(b.timeMs,b.data.byteLength);return b}.bind(this))["catch"](function(a){a&&(goog.asserts.assert(a instanceof shaka.util.Error,"Wrong error type"),a.severity=shaka.util.Error.Severity.CRITICAL);0<=this.requests_.indexOf(g)&&this.requests_.splice(this.requests_.indexOf(g),1);return Promise.reject(a)}.bind(this))};goog.exportProperty(shaka.net.NetworkingEngine.prototype,"request",shaka.net.NetworkingEngine.prototype.request); shaka.net.NetworkingEngine.prototype.send_=function(a,b,c,d,e,f){if(this.destroyed_||f())return Promise.reject();var g=new goog.Uri(b.uris[d]),h=g.getScheme();h||(h=shaka.net.NetworkingEngine.getLocationProtocol_(),goog.asserts.assert(":"==h[h.length-1],"location.protocol expected to end with a colon!"),h=h.slice(0,-1),g.setScheme(h),b.uris[d]=g.toString());h=shaka.net.NetworkingEngine.schemes_[h];if(!h)return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.NETWORK, shaka.util.Error.Code.UNSUPPORTED_SCHEME,g));var k=Date.now();return h(b.uris[d],b,a).then(function(b){void 0==b.timeMs&&(b.timeMs=Date.now()-k);var c=Date.now(),d=Promise.resolve();this.responseFilters_.forEach(function(c){d=d.then(function(){return Promise.resolve(c(a,b))}.bind(this))}.bind(this));d=d["catch"](function(a){var b=shaka.util.Error.Severity.CRITICAL;a instanceof shaka.util.Error&&(b=a.severity);throw new shaka.util.Error(b,shaka.util.Error.Category.NETWORK,shaka.util.Error.Code.RESPONSE_FILTER_ERROR, a);});return d.then(function(){b.timeMs+=Date.now()-c;b.timeMs+=e;return b})}.bind(this))["catch"](function(g){if(g&&g.severity==shaka.util.Error.Severity.RECOVERABLE)return d=(d+1)%b.uris.length,f()?Promise.reject():c.attempt().then(function(){return this.send_(a,b,c,d,e,f)}.bind(this),function(){throw g;});throw g;}.bind(this))};shaka.net.NetworkingEngine.getLocationProtocol_=function(){return location.protocol};shaka.util.ArrayUtils={};shaka.util.ArrayUtils.removeDuplicates=function(a,b){for(var c=[],d=0;d<a.length;++d){for(var e=!1,f=0;f<c.length&&!(e=b?b(a[d],c[f]):a[d]===c[f]);++f);e||c.push(a[d])}return c};shaka.util.ArrayUtils.indexOf=function(a,b,c){for(var d=0;d<a.length;++d)if(c(a[d],b))return d;return-1};shaka.util.ArrayUtils.remove=function(a,b){var c=a.indexOf(b);-1<c&&a.splice(c,1)};shaka.util.MultiMap=function(){this.map_={}};shaka.util.MultiMap.prototype.push=function(a,b){this.map_.hasOwnProperty(a)?this.map_[a].push(b):this.map_[a]=[b]};shaka.util.MultiMap.prototype.get=function(a){return(a=this.map_[a])?a.slice():null};shaka.util.MultiMap.prototype.getAll=function(){var a=[],b;for(b in this.map_)a.push.apply(a,this.map_[b]);return a};shaka.util.MultiMap.prototype.remove=function(a,b){var c=this.map_[a];if(c)for(var d=0;d<c.length;++d)c[d]==b&&(c.splice(d,1),--d)}; shaka.util.MultiMap.prototype.clear=function(){this.map_={}};shaka.util.EventManager=function(){this.bindingMap_=new shaka.util.MultiMap};shaka.util.EventManager.prototype.destroy=function(){this.removeAll();this.bindingMap_=null;return Promise.resolve()};shaka.util.EventManager.prototype.listen=function(a,b,c){this.bindingMap_&&(a=new shaka.util.EventManager.Binding_(a,b,c),this.bindingMap_.push(b,a))};shaka.util.EventManager.prototype.listenOnce=function(a,b,c){this.listen(a,b,function(d){this.unlisten(a,b);c(d)}.bind(this))}; shaka.util.EventManager.prototype.unlisten=function(a,b){if(this.bindingMap_)for(var c=this.bindingMap_.get(b)||[],d=0;d<c.length;++d){var e=c[d];e.target==a&&(e.unlisten(),this.bindingMap_.remove(b,e))}};shaka.util.EventManager.prototype.removeAll=function(){if(this.bindingMap_){for(var a=this.bindingMap_.getAll(),b=0;b<a.length;++b)a[b].unlisten();this.bindingMap_.clear()}}; shaka.util.EventManager.Binding_=function(a,b,c){this.target=a;this.type=b;this.listener=c;this.target.addEventListener(b,c,!1)};shaka.util.EventManager.Binding_.prototype.unlisten=function(){goog.asserts.assert(this.target,"Missing target");this.target.removeEventListener(this.type,this.listener,!1);this.listener=this.target=null};shaka.util.FakeEvent=function(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?window.performance.now():Date.now();this.type=a;this.isTrusted=!1;this.target=this.currentTarget=null;this.stopped=!1};shaka.util.FakeEvent.prototype.preventDefault=function(){this.cancelable&&(this.defaultPrevented=!0)};shaka.util.FakeEvent.prototype.stopImmediatePropagation=function(){this.stopped=!0}; shaka.util.FakeEvent.prototype.stopPropagation=function(){};shaka.util.ManifestParserUtils={};shaka.util.ManifestParserUtils.resolveUris=function(a,b){var c=shaka.util.Functional;if(0==b.length)return a;var d=b.map(function(a){return new goog.Uri(a)});return a.map(function(a){return new goog.Uri(a)}).map(function(a){return d.map(a.resolve.bind(a))}).reduce(c.collapseArrays,[]).map(function(a){return a.toString()})}; shaka.util.ManifestParserUtils.createDrmInfo=function(a,b){return{keySystem:a,licenseServerUri:"",distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:b||[],keyIds:[]}};shaka.util.ManifestParserUtils.ContentType={VIDEO:"video",AUDIO:"audio",TEXT:"text",APPLICATION:"application"};shaka.util.ManifestParserUtils.TextStreamKind={SUBTITLE:"subtitle",CLOSED_CAPTION:"caption"}; shaka.util.ManifestParserUtils.GAP_OVERLAP_TOLERANCE_SECONDS=1/15;shaka.util.MapUtils={};shaka.util.MapUtils.empty=function(a){return!a||0==Object.keys(a).length};shaka.util.MapUtils.values=function(a){return Object.keys(a).map(function(b){return a[b]})};shaka.util.MapUtils.map=function(a,b){return Object.keys(a).reduce(function(c,d){c[d]=b(a[d],d);return c},{})};shaka.util.MapUtils.every=function(a,b){return Object.keys(a).every(function(c){return b(c,a[c])})};shaka.util.MapUtils.forEach=function(a,b){Object.keys(a).forEach(function(c){b(c,a[c])})};shaka.util.MimeUtils={};shaka.util.MimeUtils.getFullType=function(a,b){var c=a;b&&(c+='; codecs="'+b+'"');return c};shaka.util.MimeUtils.getExtendedType=function(a){var b=a.mimeType,c;for(c in shaka.util.MimeUtils.EXTENDED_MIME_PARAMETERS_){var d=a[c],e=shaka.util.MimeUtils.EXTENDED_MIME_PARAMETERS_[c];d&&(b+="; "+e+'="'+d+'"')}return b};shaka.util.MimeUtils.EXTENDED_MIME_PARAMETERS_={codecs:"codecs",frameRate:"framerate",bandwidth:"bitrate",width:"width",height:"height",channelsCount:"channels"};shaka.util.StringUtils={};shaka.util.StringUtils.fromUTF8=function(a){if(!a)return"";a=new Uint8Array(a);239==a[0]&&187==a[1]&&191==a[2]&&(a=a.subarray(3));a=shaka.util.StringUtils.fromCharCode_(a);a=escape(a);try{return decodeURIComponent(a)}catch(b){throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BAD_ENCODING);}};goog.exportSymbol("shaka.util.StringUtils.fromUTF8",shaka.util.StringUtils.fromUTF8); shaka.util.StringUtils.fromUTF16=function(a,b,c){if(!a)return"";if(!c&&0!=a.byteLength%2)throw shaka.log.error("Data has an incorrect length, must be even."),new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.BAD_ENCODING);if(a instanceof ArrayBuffer)var d=a;else c=new Uint8Array(a.byteLength),c.set(new Uint8Array(a)),d=c.buffer;a=Math.floor(a.byteLength/2);c=new Uint16Array(a);d=new DataView(d);for(var e=0;e<a;e++)c[e]=d.getUint16(2*e,b); return shaka.util.StringUtils.fromCharCode_(c)};goog.exportSymbol("shaka.util.StringUtils.fromUTF16",shaka.util.StringUtils.fromUTF16); shaka.util.StringUtils.fromBytesAutoDetect=function(a){var b=shaka.util.StringUtils,c=new Uint8Array(a);if(239==c[0]&&187==c[1]&&191==c[2])return b.fromUTF8(c);if(254==c[0]&&255==c[1])return b.fromUTF16(c.subarray(2),!1);if(255==c[0]&&254==c[1])return b.fromUTF16(c.subarray(2),!0);var d=function(a,b){return a.byteLength<=b||32<=a[b]&&126>=a[b]}.bind(null,c);shaka.log.debug("Unable to find byte-order-mark, making an educated guess.");if(0==c[0]&&0==c[2])return b.fromUTF16(a,!1);if(0==c[1]&&0==c[3])return b.fromUTF16(a, !0);if(d(0)&&d(1)&&d(2)&&d(3))return b.fromUTF8(a);throw new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.TEXT,shaka.util.Error.Code.UNABLE_TO_DETECT_ENCODING);};goog.exportSymbol("shaka.util.StringUtils.fromBytesAutoDetect",shaka.util.StringUtils.fromBytesAutoDetect);shaka.util.StringUtils.toUTF8=function(a){a=encodeURIComponent(a);a=unescape(a);for(var b=new Uint8Array(a.length),c=0;c<a.length;++c)b[c]=a.charCodeAt(c);return b.buffer}; goog.exportSymbol("shaka.util.StringUtils.toUTF8",shaka.util.StringUtils.toUTF8);shaka.util.StringUtils.fromCharCode_=function(a){for(var b="",c=0;c<a.length;c+=16E3)var d=a.subarray(c,c+16E3),b=b+String.fromCharCode.apply(null,d);return b};shaka.util.Timer=function(a){this.id_=null;this.callback_=function(){this.id_=null;a()}.bind(this)};shaka.util.Timer.prototype.cancel=function(){null!=this.id_&&(clearTimeout(this.id_),this.id_=null)};shaka.util.Timer.prototype.schedule=function(a){this.cancel();this.id_=setTimeout(this.callback_,1E3*a)};shaka.util.Timer.prototype.scheduleRepeated=function(a){this.cancel();var b=function(){this.callback_();this.id_=setTimeout(b,1E3*a)}.bind(this);this.id_=setTimeout(b,1E3*a)};shaka.util.Uint8ArrayUtils={};shaka.util.Uint8ArrayUtils.toBase64=function(a,b){var c=String.fromCharCode.apply(null,a),d=void 0==b?!0:b,c=window.btoa(c).replace(/\+/g,"-").replace(/\//g,"_");return d?c:c.replace(/=*$/,"")};goog.exportSymbol("shaka.util.Uint8ArrayUtils.toBase64",shaka.util.Uint8ArrayUtils.toBase64);shaka.util.Uint8ArrayUtils.fromBase64=function(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}; goog.exportSymbol("shaka.util.Uint8ArrayUtils.fromBase64",shaka.util.Uint8ArrayUtils.fromBase64);shaka.util.Uint8ArrayUtils.fromHex=function(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};goog.exportSymbol("shaka.util.Uint8ArrayUtils.fromHex",shaka.util.Uint8ArrayUtils.fromHex);shaka.util.Uint8ArrayUtils.toHex=function(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}; goog.exportSymbol("shaka.util.Uint8ArrayUtils.toHex",shaka.util.Uint8ArrayUtils.toHex);shaka.util.Uint8ArrayUtils.equal=function(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};goog.exportSymbol("shaka.util.Uint8ArrayUtils.equal",shaka.util.Uint8ArrayUtils.equal); shaka.util.Uint8ArrayUtils.concat=function(a){for(var b=0,c=0;c<arguments.length;++c)b+=arguments[c].length;for(var b=new Uint8Array(b),d=0,c=0;c<arguments.length;++c)b.set(arguments[c],d),d+=arguments[c].length;return b};goog.exportSymbol("shaka.util.Uint8ArrayUtils.concat",shaka.util.Uint8ArrayUtils.concat);shaka.media={}; shaka.media.DrmEngine=function(a){this.playerInterface_=a;this.video_=this.mediaKeys_=this.supportedTypes_=null;this.initialized_=!1;this.currentDrmInfo_=null;this.eventManager_=new shaka.util.EventManager;this.activeSessions_=[];this.offlineSessionIds_=[];this.allSessionsLoaded_=new shaka.util.PublicPromise;this.config_=null;this.onError_=function(b){this.allSessionsLoaded_.reject(b);a.onError(b)}.bind(this);this.keyStatusByKeyId_={};this.keyStatusTimer_=new shaka.util.Timer(this.processKeyStatusChanges_.bind(this));this.isOffline_= this.destroyed_=!1;this.mediaKeyMessageEvents_=[];this.initialRequestsSent_=!1;this.expirationTimer_=new shaka.util.Timer(this.pollExpiration_.bind(this));this.expirationTimer_.scheduleRepeated(1);this.allSessionsLoaded_["catch"](function(){})}; shaka.media.DrmEngine.prototype.destroy=function(){var a=shaka.util.Functional;this.destroyed_=!0;var b=[];this.activeSessions_.forEach(function(c){c=c.session.close()["catch"](a.noop);var d=new Promise(function(a){setTimeout(a,1E3)});b.push(Promise.race([c,d]))});this.allSessionsLoaded_.reject();this.eventManager_&&b.push(this.eventManager_.destroy());this.video_&&(goog.asserts.assert(!this.video_.src,"video src must be removed first!"),b.push(this.video_.setMediaKeys(null)["catch"](a.noop)));this.expirationTimer_&& (this.expirationTimer_.cancel(),this.expirationTimer_=null);this.keyStatusTimer_&&(this.keyStatusTimer_.cancel(),this.keyStatusTimer_=null);this.eventManager_=this.video_=this.mediaKeys_=this.supportedTypes_=this.currentDrmInfo_=null;this.activeSessions_=[];this.offlineSessionIds_=[];this.playerInterface_=this.onError_=this.config_=null;return Promise.all(b)};shaka.media.DrmEngine.prototype.configure=function(a){this.config_=a}; shaka.media.DrmEngine.prototype.init=function(a,b){goog.asserts.assert(this.config_,"DrmEngine configure() must be called before init()!");var c={},d=[];this.isOffline_=b;this.offlineSessionIds_=a.offlineSessionIds;this.prepareMediaKeyConfigs_(a,b||0<a.offlineSessionIds.length,c,d);return d.length?this.queryMediaKeys_(c,d):(this.initialized_=!0,Promise.resolve())}; shaka.media.DrmEngine.prototype.attach=function(a){if(!this.mediaKeys_)return this.eventManager_.listenOnce(a,"encrypted",function(a){this.onError_(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.ENCRYPTED_CONTENT_WITHOUT_DRM_INFO))}.bind(this)),Promise.resolve();this.video_=a;this.eventManager_.listenOnce(this.video_,"play",this.onPlay_.bind(this));a=this.video_.setMediaKeys(this.mediaKeys_);a=a["catch"](function(a){return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_ATTACH_TO_VIDEO,a.message))});var b=null;this.currentDrmInfo_.serverCertificate&&this.currentDrmInfo_.serverCertificate.length&&(b=this.mediaKeys_.setServerCertificate(this.currentDrmInfo_.serverCertificate).then(function(a){a||shaka.log.warning("Server certificates are not supported by the key system. The server certificate has been ignored.")})["catch"](function(a){return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL, shaka.util.Error.Category.DRM,shaka.util.Error.Code.INVALID_SERVER_CERTIFICATE,a.message))}));return Promise.all([a,b]).then(function(){if(this.destroyed_)return Promise.reject();this.createOrLoad();if(!this.currentDrmInfo_.initData.length&&!this.offlineSessionIds_.length){var a=this.onEncrypted_.bind(this);this.eventManager_.listen(this.video_,"encrypted",a)}}.bind(this))["catch"](function(a){return this.destroyed_?Promise.resolve():Promise.reject(a)}.bind(this))}; shaka.media.DrmEngine.prototype.removeSessions=function(a){goog.asserts.assert(this.mediaKeys_||!a.length,"Must call init() before removeSessions");return Promise.all(a.map(function(a){return this.loadOfflineSession_(a).then(function(a){if(a){for(var b=new shaka.util.PublicPromise,c=0;c<this.activeSessions_.length;c++)if(this.activeSessions_[c].session==a){this.activeSessions_[c].updatePromise=b;break}return Promise.all([a.remove(),b])}}.bind(this))}.bind(this)))}; shaka.media.DrmEngine.prototype.createOrLoad=function(){var a=this.currentDrmInfo_?this.currentDrmInfo_.initData:[];a.forEach(function(a){this.createTemporarySession_(a.initDataType,a.initData)}.bind(this));this.offlineSessionIds_.forEach(function(a){this.loadOfflineSession_(a)}.bind(this));a.length||this.offlineSessionIds_.length||this.allSessionsLoaded_.resolve();return this.allSessionsLoaded_};shaka.media.DrmEngine.prototype.initialized=function(){return this.initialized_}; shaka.media.DrmEngine.prototype.keySystem=function(){return this.currentDrmInfo_?this.currentDrmInfo_.keySystem:""};shaka.media.DrmEngine.prototype.getSupportedTypes=function(){return this.supportedTypes_};shaka.media.DrmEngine.prototype.getSessionIds=function(){return this.activeSessions_.map(function(a){return a.session.sessionId})}; shaka.media.DrmEngine.prototype.getExpiration=function(){var a=this.activeSessions_.map(function(a){a=a.session.expiration;return isNaN(a)?Infinity:a});return Math.min.apply(Math,a)};shaka.media.DrmEngine.prototype.getDrmInfo=function(){return this.currentDrmInfo_}; shaka.media.DrmEngine.prototype.prepareMediaKeyConfigs_=function(a,b,c,d){var e=this.configureClearKey_();a.periods.forEach(function(a){a.variants.forEach(function(a){e&&(a.drmInfos=[e]);a.drmInfos.forEach(function(e){this.fillInDrmInfoDefaults_(e);window.cast&&window.cast.__platform__&&"com.microsoft.playready"==e.keySystem&&(e.keySystem="com.chromecast.playready");var f=c[e.keySystem];f||(f={audioCapabilities:[],videoCapabilities:[],distinctiveIdentifier:"optional",persistentState:b?"required": "optional",sessionTypes:[b?"persistent-license":"temporary"],label:e.keySystem,drmInfos:[]},c[e.keySystem]=f,d.push(e.keySystem));f.drmInfos.push(e);e.distinctiveIdentifierRequired&&(f.distinctiveIdentifier="required");e.persistentStateRequired&&(f.persistentState="required");var g=[];a.video&&g.push(a.video);a.audio&&g.push(a.audio);g.forEach(function(a){var b=shaka.util.ManifestParserUtils.ContentType,c=a.type==b.VIDEO?f.videoCapabilities:f.audioCapabilities,b=(a.type==b.VIDEO?e.videoRobustness: e.audioRobustness)||"";a=shaka.util.MimeUtils.getFullType(a.mimeType,a.codecs);c.push({robustness:b,contentType:a})}.bind(this))}.bind(this))}.bind(this))}.bind(this))}; shaka.media.DrmEngine.prototype.queryMediaKeys_=function(a,b){if(1==b.length&&""==b[0])return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.NO_RECOGNIZED_KEY_SYSTEMS));var c=new shaka.util.PublicPromise,d=c;[!0,!1].forEach(function(c){b.forEach(function(b){var e=a[b];e.drmInfos.some(function(a){return!!a.licenseServerUri})==c&&(0==e.audioCapabilities.length&&delete e.audioCapabilities,0==e.videoCapabilities.length&&delete e.videoCapabilities, d=d["catch"](function(){return this.destroyed_?Promise.reject():navigator.requestMediaKeySystemAccess(b,[e])}.bind(this)))}.bind(this))}.bind(this));d=d["catch"](function(){return Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.REQUESTED_KEY_SYSTEM_CONFIG_UNAVAILABLE))});d=d.then(function(b){if(this.destroyed_)return Promise.reject();var c=0<=navigator.userAgent.indexOf("Edge/"),d=b.getConfiguration();this.supportedTypes_= (d.audioCapabilities||[]).concat(d.videoCapabilities||[]).map(function(a){return a.contentType});c&&(this.supportedTypes_=null);goog.asserts.assert(!this.supportedTypes_||this.supportedTypes_.length,"We should get at least one supported MIME type");c=a[b.keySystem];this.createCurrentDrmInfo_(b.keySystem,c,c.drmInfos);return this.currentDrmInfo_.licenseServerUri?b.createMediaKeys():Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.NO_LICENSE_SERVER_GIVEN))}.bind(this)).then(function(a){if(this.destroyed_)return Promise.reject(); this.mediaKeys_=a;this.initialized_=!0}.bind(this))["catch"](function(a){if(this.destroyed_)return Promise.resolve();this.supportedTypes_=this.currentDrmInfo_=null;return a instanceof shaka.util.Error?Promise.reject(a):Promise.reject(new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_CDM,a.message))}.bind(this));c.reject();return d}; shaka.media.DrmEngine.prototype.fillInDrmInfoDefaults_=function(a){var b=a.keySystem;if(b){if(!a.licenseServerUri){var c=this.config_.servers[b];c?a.licenseServerUri=c:shaka.log.error("No license server configured for "+b)}a.keyIds||(a.keyIds=[]);if(b=this.config_.advanced[b])a.distinctiveIdentifierRequired||(a.distinctiveIdentifierRequired=b.distinctiveIdentifierRequired),a.persistentStateRequired||(a.persistentStateRequired=b.persistentStateRequired),a.videoRobustness||(a.videoRobustness=b.videoRobustness), a.audioRobustness||(a.audioRobustness=b.audioRobustness),a.serverCertificate||(a.serverCertificate=b.serverCertificate)}}; shaka.media.DrmEngine.prototype.configureClearKey_=function(){if(shaka.util.MapUtils.empty(this.config_.clearKeys))return null;var a=shaka.util.StringUtils,b=shaka.util.Uint8ArrayUtils,c=[],d=[],e;for(e in this.config_.clearKeys){var f=this.config_.clearKeys[e],g=b.fromHex(e),f=b.fromHex(f),g={kty:"oct",kid:b.toBase64(g,!1),k:b.toBase64(f,!1)};c.push(g);d.push(g.kid)}b=JSON.stringify({keys:c});d=JSON.stringify({kids:d});a=[{initData:new Uint8Array(a.toUTF8(d)),initDataType:"keyids"}];return{keySystem:"org.w3.clearkey", licenseServerUri:"data:application/json;base64,"+window.btoa(b),distinctiveIdentifierRequired:!1,persistentStateRequired:!1,audioRobustness:"",videoRobustness:"",serverCertificate:null,initData:a,keyIds:[]}}; shaka.media.DrmEngine.prototype.createCurrentDrmInfo_=function(a,b,c){var d=[],e=[],f=[],g=[];this.processDrmInfos_(c,d,e,f,g);1<e.length&&shaka.log.warning("Multiple unique server certificates found! Only the first will be used.");1<d.length&&shaka.log.warning("Multiple unique license server URIs found! Only the first will be used.");this.currentDrmInfo_={keySystem:a,licenseServerUri:d[0],distinctiveIdentifierRequired:"required"==b.distinctiveIdentifier,persistentStateRequired:"required"==b.persistentState, audioRobustness:b.audioCapabilities?b.audioCapabilities[0].robustness:"",videoRobustness:b.videoCapabilities?b.videoCapabilities[0].robustness:"",serverCertificate:e[0],initData:f,keyIds:g}}; shaka.media.DrmEngine.prototype.processDrmInfos_=function(a,b,c,d,e){function f(a,b){return a.keyId&&a.keyId==b.keyId?!0:a.initDataType==b.initDataType&&shaka.util.Uint8ArrayUtils.equal(a.initData,b.initData)}a.forEach(function(a){var g=shaka.util.ArrayUtils,k=shaka.util.Uint8ArrayUtils;-1==b.indexOf(a.licenseServerUri)&&b.push(a.licenseServerUri);a.serverCertificate&&-1==g.indexOf(c,a.serverCertificate,k.equal)&&c.push(a.serverCertificate);a.initData&&a.initData.forEach(function(a){-1==g.indexOf(d, a,f)&&d.push(a)});if(a.keyIds)for(k=0;k<a.keyIds.length;++k)-1==e.indexOf(a.keyIds[k])&&e.push(a.keyIds[k])})};shaka.media.DrmEngine.prototype.onEncrypted_=function(a){for(var b=shaka.util.Uint8ArrayUtils,c=new Uint8Array(a.initData),d=0;d<this.activeSessions_.length;++d)if(b.equal(c,this.activeSessions_[d].initData)){shaka.log.debug("Ignoring duplicate init data.");return}this.createTemporarySession_(a.initDataType,c)}; shaka.media.DrmEngine.prototype.loadOfflineSession_=function(a){try{var b=this.mediaKeys_.createSession("persistent-license")}catch(d){return a=new shaka.util.Error(shaka.util.Error.Severity.CRITICAL,shaka.util.Error.Category.DRM,shaka.util.Error.Code.FAILED_TO_CREATE_SESSION,d.message),this.onError_(a),Promise.reject(a)}this.eventManager_.listen(b,"message",this.onSessionMessage_.bind(this));this.eventManager_.listen(b,"keystatuseschange",this.onKeyStatusesChange_.bind(this));var c={initData:null, session:b,loaded:!1,oldExpiration:Infinity,updatePromise:nul