jellyfin-web/dashboard-ui/bower_components/hls.js/dist/hls.min.js

6 lines
126 KiB
JavaScript
Raw Normal View History

2016-04-16 09:51:35 -07:00
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Hls=e()}}(function(){return function s(e,t,r){function i(n,d){if(!t[n]){if(!e[n]){var l="function"==typeof require&&require;if(!d&&l)return l(n,!0);if(a)return a(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var o=t[n]={exports:{}};e[n][0].call(o.exports,function(t){var r=e[n][1][t];return i(r?r:t)},o,o.exports,s,e,t,r)}return t[n].exports}for(var a="function"==typeof require&&require,n=0;n<r.length;n++)i(r[n]);return i}({1:[function(s,n,o){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function t(e){return"function"==typeof e}function a(e){return"number"==typeof e}function r(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}n.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if(!a(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},e.prototype.emit=function(l){var s,e,u,n,a,o;if(this._events||(this._events={}),"error"===l&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if(s=arguments[1],s instanceof Error)throw s;throw TypeError('Uncaught, unspecified "error" event.')}if(e=this._events[l],i(e))return!1;if(t(e))switch(arguments.length){case 1:e.call(this);break;case 2:e.call(this,arguments[1]);break;case 3:e.call(this,arguments[1],arguments[2]);break;default:n=Array.prototype.slice.call(arguments,1),e.apply(this,n)}else if(r(e))for(n=Array.prototype.slice.call(arguments,1),o=e.slice(),u=o.length,a=0;u>a;a++)o[a].apply(this,n);return!0},e.prototype.addListener=function(n,a){var s;if(!t(a))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",n,t(a.listener)?a.listener:a),this._events[n]?r(this._events[n])?this._events[n].push(a):this._events[n]=[this._events[n],a]:this._events[n]=a,r(this._events[n])&&!this._events[n].warned&&(s=i(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[n].length>s&&(this._events[n].warned=!0,"function"==typeof console.trace)),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(i,e){function r(){this.removeListener(i,r),n||(n=!0,e.apply(this,arguments))}if(!t(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(i,r),this},e.prototype.removeListener=function(n,i){var e,s,o,a;if(!t(i))throw TypeError("listener must be a function");if(!this._events||!this._events[n])return this;if(e=this._events[n],o=e.length,s=-1,e===i||t(e.listener)&&e.listener===i)delete this._events[n],this._events.removeListener&&this.emit("removeListener",n,i);else if(r(e)){for(a=o;a-- >0;)if(e[a]===i||e[a].listener&&e[a].listener===i){s=a;break}if(0>s)return this;1===e.length?(e.length=0,delete this._events[n]):e.splice(s,1),this._events.removeListener&&this.emit("removeListener",n,i)}return this},e.prototype.removeAllListeners=function(r){var i,e;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[r]&&delete this._events[r],this;if(0===arguments.length){for(i in this._events)"removeListener"!==i&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events={},this}if(e=this._events[r],t(e))this.removeListener(r,e);else if(e)for(;e.length;)this.removeListener(r,e[e.length-1]);return delete this._events[r],this},e.prototype.listeners=function(e){var r;return r=this._events&&this._events[e]?t(this._events[e])?[this._events[e]]:this._events[e].slice():[]},e.prototype.listenerCount=function(r){if(this._events){var e=this._events[r];if(t(e))return 1;if(e)return e.length}return 0},e.listenerCount=function(e,t){return e.listenerCount(t)}},{}]
this.seekAfterBuffered=g+Math.max(0,a.totalduration-T),t.logger.log("buffer end: "+u+" is located too far from the end of live sliding playlist, media position will be reseted to: "+this.seekAfterBuffered.toFixed(3)),u=this.seekAfterBuffered}if(u>y)break;if(this.startFragRequested&&!a.PTSKnown){if(v){var E=v.sn+1;E>=a.startSN&&E<=a.endSN&&(n=d[E-a.startSN],t.logger.log("live playlist, switching playlist, load frag with next SN: "+n.sn))}n||(n=d[Math.min(h-1,Math.round(h/2))],t.logger.log("live playlist, switching playlist, unknown, load middle frag : "+n.sn))}}else g>u&&(n=d[0]);if(n||!function(){var i=void 0,s=o.maxFragLookUpTolerance;y>u?(u>y-s&&(s=0),i=p.default.search(d,function(e){return e.start+e.duration-s<=u?1:e.start-s>u?-1:0})):i=d[h-1],i&&(n=i,g=i.start,v&&n.level===v.level&&n.sn===v.sn&&(n.sn<a.endSN?(n=d[n.sn+1-a.startSN],t.logger.log("SN just loaded, load next one: "+n.sn)):(a.live||(_.hls.trigger(r.default.BUFFER_EOS),_.state=e.ENDED),n=null)))}(),n)if(null!=n.decryptdata.uri&&null==n.decryptdata.key)t.logger.log("Loading key for "+n.sn+" of ["+a.startSN+" ,"+a.endSN+"],level "+l),this.state=e.KEY_LOADING,f.trigger(r.default.KEY_LOADING,{frag:n});else{if(t.logger.log("Loading "+n.sn+" of ["+a.startSN+" ,"+a.endSN+"],level "+l+", currentTime:"+m+",bufferEnd:"+u.toFixed(3)),n.autoLevel=f.autoLevelEnabled,this.levels.length>1&&(n.expectedLen=Math.round(n.duration*this.levels[l].bitrate/8),n.trequest=performance.now()),void 0!==this.fragLoadIdx?this.fragLoadIdx++:this.fragLoadIdx=0,n.loadCounter){n.loadCounter++;var R=o.fragLoadingLoopThreshold;if(n.loadCounter>R&&Math.abs(this.fragLoadIdx-n.loadIdx)<R)return void f.trigger(r.default.ERROR,{type:i.ErrorTypes.MEDIA_ERROR,details:i.ErrorDetails.FRAG_LOOP_LOADING_ERROR,fatal:!1,frag:n})}else n.loadCounter=1;n.loadIdx=this.fragLoadIdx,this.fragCurrent=n,this.startFragRequested=!0,f.trigger(r.default.FRAG_LOADING,{frag:n}),this.state=e.FRAG_LOADING}}break;case e.WAITING_LEVEL:l=this.levels[this.level],l&&l.details&&(this.state=e.IDLE);break;case e.FRAG_LOADING_WAITING_RETRY:var w=performance.now(),A=this.retryDate,L=this.media,D=L&&L.seeking;(!A||w>=A||D)&&(t.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=e.IDLE);break;case e.STOPPED:case e.FRAG_LOADING:case e.PARSING:case e.PARSED:case e.ENDED:}this._checkBuffer(),this._checkFragmentChanged()}},{key:"getBufferRange",value:function(i){var e,t,r=this.bufferRange;if(r)for(e=r.length-1;e>=0;e--)if(t=r[e],i>=t.start&&i<=t.end)return t;return null}},{key:"followingBufferRange",value:function(e){return e?this.getBufferRange(e.end+.5):null}},{key:"isBuffered",value:function(r){for(var i=this.media,t=i.buffered,e=0;e<t.length;e++)if(r>=t.start(e)&&r<=t.end(e))return!0;return!1}},{key:"_checkFragmentChanged",value:function(){var t,e,i=this.media;if(i&&i.seeking===!1&&(e=i.currentTime,e>i.playbackRate*this.lastCurrentTime&&(this.lastCurrentTime=e),this.isBuffered(e)?t=this.getBufferRange(e):this.isBuffered(e+.1)&&(t=this.getBufferRange(e+.1)),t)){var n=t.frag;n!==this.fragPlaying&&(this.fragPlaying=n,this.hls.trigger(r.default.FRAG_CHANGED,{frag:n}))}}},{key:"immediateLevelSwitch",value:function(){t.logger.log("immediateLevelSwitch"),this.immediateSwitch||(this.immediateSwitch=!0,this.previouslyPaused=this.media.paused,this.media.pause());var i=this.fragCurrent;i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY}),this.state=e.PAUSED,this.fragLoadIdx+=2*this.config.fragLoadingLoopThreshold,this.tick()}},{key:"immediateLevelSwitchEnd",value:function(){this.immediateSwitch=!1,this.media.currentTime-=1e-4,this.previouslyPaused||this.media.play()}},{key:"nextLevelSwitch",value:function(){var n,i,t;if(i=this.getBufferRange(this.media.currentTime),i&&i.start>1&&(this.hls.trigger(r.default.BUFFER_FLUSHING,{startOffset:0,endOffset:i.start-1}),this.state=e.PAUSED),this.media.paused)n=0;else{var o=this.hls.nextLoadLevel,l=this.levels[o],s=this.fragLastKbps;n=s&&this.fragCurrent?this.fragCurrent.duration
samples:t.samples});break;default:this.hls.trigger(t.event,t.data)}}}]),r}();i.default=o},{"../crypt/decrypter":12,"../demux/demuxer-inline":15,"../demux/demuxer-worker":16,"../events":23,"../utils/logger":37,webworkify:2}],18:[function(t,s,e){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),n=t("../utils/logger"),a=function(){function e(t){r(this,e),this.data=t,this.bytesAvailable=this.data.byteLength,this.word=0,this.bitsAvailable=0}return i(e,[{key:"loadWord",value:function(){var t=this.data.byteLength-this.bytesAvailable,r=new Uint8Array(4),e=Math.min(4,this.bytesAvailable);if(0===e)throw new Error("no bytes available");r.set(this.data.subarray(t,t+e)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e}},{key:"skipBits",value:function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;return t>32&&n.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0?this.word<<=e:this.bytesAvailable>0&&this.loadWord(),e=t-e,e>0?r<<e|this.readBits(e):r}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!==(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}},{key:"skipScalingList",value:function(n){var t,i,r=8,e=8;for(t=0;n>t;t++)0!==e&&(i=this.readEG(),e=(r+i+256)%256),r=0===e?r:e}},{key:"readSPS",value:function(){var t,g,p,l,n,a,i,o,r,s=0,d=0,f=0,h=0,c=1;if(this.readUByte(),t=this.readUByte(),g=this.readBits(5),this.skipBits(3),p=this.readUByte(),this.skipUEG(),100===t||110===t||122===t||244===t||44===t||83===t||86===t||118===t||128===t){var v=this.readUEG();if(3===v&&this.skipBits(1),this.skipUEG(),this.skipUEG(),this.skipBits(1),this.readBoolean())for(o=3!==v?8:12,r=0;o>r;r++)this.readBoolean()&&(6>r?this.skipScalingList(16):this.skipScalingList(64))}this.skipUEG();var u=this.readUEG();if(0===u)this.readUEG();else if(1===u)for(this.skipBits(1),this.skipEG(),this.skipEG(),l=this.readUEG(),r=0;l>r;r++)this.skipEG();if(this.skipUEG(),this.skipBits(1),n=this.readUEG(),a=this.readUEG(),i=this.readBits(1),0===i&&this.skipBits(1),this.skipBits(1),this.readBoolean()&&(s=this.readUEG(),d=this.readUEG(),f=this.readUEG(),h=this.readUEG()),this.readBoolean()&&this.readBoolean()){var e=void 0,y=this.readUByte();switch(y){case 1:e=[1,1];break;case 2:e=[12,11];break;case 3:e=[10,11];break;case 4:e=[16,11];break;case 5:e=[40,33];break;case 6:e=[24,11];break;case 7:e=[20,11];break;case 8:e=[32,11];break;case 9:e=[80,33];break;case 10:e=[18,11];break;case 11:e=[15,11];break;case 12:e=[64,33];break;case 13:e=[160,99];break;case 14:e=[4,3];break;case 15:e=[3,2];break;case 16:e=[2,1];break;case 255:e=[this.readUByte()<<8|this.readUByte(),this.readUByte()<<8|this.readUByte()]}e&&(c=e[0]/e[1])}return{width:Math.ceil((16*(n+1)-2*s-2*d)*c),height:(2-i)*(a+1)*16-(i?2:4)*(f+h)}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),e}();e.defau
value:!0});var h=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=r("../events"),e=n(l),d=r("../event-handler"),a=n(d),t=r("../errors"),o=function(i){function r(i){u(this,r);var t=f(this,Object.getPrototypeOf(r).call(this,i,e.default.KEY_LOADING));return t.decryptkey=null,t.decrypturl=null,t}return s(r,i),h(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),a.default.prototype.destroy.call(this)}},{key:"onKeyLoading",value:function(a){var t=this.frag=a.frag,n=t.decryptdata,i=n.uri;if(i!==this.decrypturl||null===this.decryptkey){var r=this.hls.config;t.loader=this.loader=new r.loader(r),this.decrypturl=i,this.decryptkey=null,t.loader.load(i,"arraybuffer",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r.fragLoadingTimeOut,r.fragLoadingMaxRetry,r.fragLoadingRetryDelay,this.loadprogress.bind(this),t)}else this.decryptkey&&(n.key=this.decryptkey,this.hls.trigger(e.default.KEY_LOADED,{frag:t}))}},{key:"loadsuccess",value:function(r){var t=this.frag;this.decryptkey=t.decryptdata.key=new Uint8Array(r.currentTarget.response),t.loader=void 0,this.hls.trigger(e.default.KEY_LOADED,{frag:t})}},{key:"loaderror",value:function(r){this.loader&&this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:this.frag,response:r})}},{key:"loadtimeout",value:function(){this.loader&&this.loader.abort(),this.hls.trigger(e.default.ERROR,{type:t.ErrorTypes.NETWORK_ERROR,details:t.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:this.frag})}},{key:"loadprogress",value:function(){}}]),r}(a.default);i.default=o},{"../errors":21,"../event-handler":22,"../events":23}],30:[function(r,y,s){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function h(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(s,"__esModule",{value:!0});var o=function(){function e(i,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}(),l=r("../events"),t=i(l),p=r("../event-handler"),a=i(p),e=r("../errors"),c=r("../utils/url"),v=i(c),g=r("../utils/attr-list"),n=i(g),u=function(i){function r(e){return d(this,r),f(this,Object.getPrototypeOf(r).call(this,e,t.default.MANIFEST_LOADING,t.default.LEVEL_LOADING))}return h(r,i),o(r,[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null),this.url=this.id=null,a.default.prototype.destroy.call(this)}},{key:"onManifestLoading",value:function(e){this.load(e.url,null)}},{key:"onLevelLoading",value:function(e){this.load(e.url,e.level,e.id)}},{key:"load",value:function(n,a,s){var t,r,i,e=this.hls.config;this.url=n,this.id=a,this.id2=s,null===this.id?(t=e.manifestLoadingMaxRetry,r=e.manifestLoadingTimeOut,i=e.manifestLoadingRetryDelay):(t=e.levelLoadingMaxRetry,r=e.levelLoadingTimeOut,i=e.levelLoadingRetryDelay),this.loader="undefined"!=typeof e.pLoader?new e.pLoader(e):new e.loader(e),this.loader.load(n,"",this.loadsuccess.bind(this),this.loaderror.bind(this),this.loadtimeout.bind(this),r,t,i)}},{key:"resolve",value:function(e,t){return v.default.buildAbsoluteURL(t,e)}},{key:"parseMasterPlaylist",value:function(f,u){for(var l=[],i=void 0,d=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)
e.onloadend=this.loadend.bind(this),e.onprogress=this.loadprogress.bind(this),e.open("GET",this.url,!0),this.byteRange&&e.setRequestHeader("Range","bytes="+this.byteRange),e.responseType=this.responseType,this.stats.tfirst=null,this.stats.loaded=0,this.xhrSetup&&this.xhrSetup(e,this.url),this.timeoutHandle=window.setTimeout(this.loadtimeout.bind(this),this.timeout),e.send()}},{key:"loadend",value:function(i){var n=i.currentTarget,r=n.status,t=this.stats;t.aborted||(r>=200&&300>r?(window.clearTimeout(this.timeoutHandle),t.tload=performance.now(),this.onSuccess(i,t)):t.retry<this.maxRetry?(e.logger.warn(r+" while loading "+this.url+", retrying in "+this.retryDelay+"..."),this.destroy(),window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,64e3),t.retry++):(window.clearTimeout(this.timeoutHandle),e.logger.error(r+" while loading "+this.url),this.onError(i)))}},{key:"loadtimeout",value:function(t){e.logger.warn("timeout while loading "+this.url),this.onTimeout(t,this.stats)}},{key:"loadprogress",value:function(t){var e=this.stats;null===e.tfirst&&(e.tfirst=performance.now()),e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total),this.onProgress&&this.onProgress(e)}}]),t}();t.default=a},{"../utils/logger":37}]},{},[27])(27)});