diff --git a/packages/xgplayer-hls/browser/index.js b/packages/xgplayer-hls/browser/index.js index 4f1871b58..648996cd7 100644 --- a/packages/xgplayer-hls/browser/index.js +++ b/packages/xgplayer-hls/browser/index.js @@ -1 +1 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";var r,i,a,o,u,s,f,c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=n(10),l=n(24),h=Function.prototype.apply,p=Function.prototype.call,v=Object.create,y=Object.defineProperty,b=Object.defineProperties,w=Object.prototype.hasOwnProperty,m={configurable:!0,enumerable:!1,writable:!0};u={on:r=function(e,t){var n;return l(t),w.call(this,"__ee__")?n=this.__ee__:(n=m.value=v(null),y(this,"__ee__",m),m.value=null),n[e]?"object"===c(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t,this},once:i=function(e,t){var n,i;return l(t),i=this,r.call(this,e,n=function(){a.call(i,e,n),h.call(t,this,arguments)}),n.__eeOnceListener__=t,this},off:a=function(e,t){var n,r,i,a;if(l(t),!w.call(this,"__ee__"))return this;if(!(n=this.__ee__)[e])return this;if("object"===(void 0===(r=n[e])?"undefined":c(r)))for(a=0;i=r[a];++a)i!==t&&i.__eeOnceListener__!==t||(2===r.length?n[e]=r[a?0:1]:r.splice(a,1));else r!==t&&r.__eeOnceListener__!==t||delete n[e];return this},emit:o=function(e){var t,n,r,i,a;if(w.call(this,"__ee__")&&(i=this.__ee__[e]))if("object"===(void 0===i?"undefined":c(i))){for(n=arguments.length,a=new Array(n-1),t=1;t>>15,this.payload=t>>>14&1,this.priority=t>>>13&1,this.pid=8191&t,t=e.readUint8(),this.scrambling=t>>6&3,this.adaptation=t>>4&3,this.continuity=15&t,this.packet=0===this.pid?"PAT":"MEDIA"}},{key:"Payload",value:function(t,n){var r=n.header.pid,i=void 0;switch(r){case 0:i=new e.PAT(t);break;case 1:i=new e.CAT(t);break;case 2:i=new e.TSDT(t);break;case 8191:i=!1;break;default:if(e.PATSpace.some(function(e){return e.pid===r}))i=new e.PMT(t,n);else{var a=e.PMTSpace?e.PMTSpace.filter(function(e){return e.pid===r}):[];i=!!a.length&&new e.Media(t,n,s[a[0].streamType][0])}}return i}},{key:"PAT",value:function(t){var n=t.readUint8();t.skip(n),n=t.readUint8(),this.tabelID=n,n=t.readUint16(),this.error=n>>>7,this.zero=n>>>6&1,this.sectionLength=4095&n,this.streamID=t.readUint16(),this.current=1&t.readUint8(),this.sectionNumber=t.readUint8(),this.lastSectionNumber=t.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=4&&(this.crc32=t.readUint32())}},{key:"PMT",value:function(t,n){var r=this;n.header.packet="PMT";var i=t.readUint8();t.skip(i),i=t.readUint8(),this.tableID=i,i=t.readUint16(),this.sectionLength=4095&i,this.program=t.readUint16(),this.current=1&t.readUint8(),this.order=t.readUint8(),this.lastOrder=t.readUint8(),this.PCR_PID=8191&t.readUint16(),this.programLength=4095&t.readUint16();for(var a=(this.sectionLength-13)/5,o=[],u=0;u=4&&(this.crc32=t.readUint32())}},{key:"Media",value:function(e,t,n){var r=t.header;if(this.start=e.position,this.type=n,3===r.adaptation&&(this.adaptationLength=e.readUint8(),this.adaptationLength>0)){var i=e.readUint8();this.discontinue=i>>>7,this.access=i>>>6&1,this.priority=i>>>5&1,this.PCR=i>>>4&1,this.OPCR=i>>>3&1,this.splicePoint=i>>>2&1,this.transportPrivate=i>>>1&1,this.adaptationField=1&i;var o=e.position;if(1===this.PCR&&(this.programClockBase=e.readUint32()<<1,i=e.readUint16(),this.programClockBase|=i>>>15,this.programClockExtension=511&i),1===this.OPCR&&(this.originProgramClockBase=e.readUint32()<<1,i=e.readUint16(),this.originProgramClockBase+=i>>>15,this.originProgramClockExtension=511&i),1===this.splicePoint&&(this.spliceCountdown=e.readUint8()),1===this.transportPrivate)for(var u=e.readUint8(),s=[],f=0;f>>6&1,p=d>>>5&1;1===d>>>7&&(d=e.readUint16(),this.ltwValid=d>>>15,this.ltwOffset=61439&d),1===h&&(d=e.readUint24(),this.piecewiseRate=4194303&d),1===p&&(d=e.readInt8(),this.spliceType=d>>>4,this.dtsNextAU1=d>>>1&7,this.marker1=1&d,d=e.readUint16(),this.dtsNextAU2=d>>>1,this.marker2=1&d,d=e.readUint16(),this.dtsNextAU3=d),e.skip(c-1-(e.position-l))}var v=this.adaptationLength-1-(e.position-o);e.skip(v)}this.buffer=new a.default(e.buffer.slice(e.position))}},{key:"PES",value:function(t){var n=t[0],r=n.body.buffer,i=r.readUint24();if(this.header=n.header,1!==i)throw new Error("this is not pes packet");var a=r.readUint8();a>=224&&a<=239&&(this.type="video"),a>=192&&a<=223&&(this.type="audio");var o=r.readUint16();if(this.packetLength=o,"video"!==this.type&&"audio"!==this.type)throw new Error("format is not supported");var u=r.readUint8();if(2!==u>>>6)throw new Error("error when parse pes header");u=r.readUint8(),this.ptsDTSFlag=u>>>6,this.escrFlag=u>>>5&1,this.esRateFlag=u>>>4&1,this.dsmFlag=u>>>3&1,this.additionalFlag=u>>>2&1,this.crcFlag=u>>>1&1,this.extensionFlag=1&u,this.pesHeaderLength=r.readUint8();var s=this.pesHeaderLength;if(2===this.ptsDTSFlag){var f=[];u=r.readUint8(),f.push(u>>>1&7),u=r.readUint16(),f.push(u>>>1),u=r.readUint16(),f.push(u>>>1),this.pts=f[0]<<30|f[1]<<15|f[2],s-=5,"video"===this.type&&(this.dts=this.pts)}if(3===this.ptsDTSFlag){var c=[];u=r.readUint8(),c.push(u>>>1&7),u=r.readUint16(),c.push(u>>>1),u=r.readUint16(),c.push(u>>>1),this.pts=c[0]<<30|c[1]<<15|c[2];var d=[];u=r.readUint8(),d.push(u>>>1&7),u=r.readUint16(),d.push(u>>>1),u=r.readUint16(),d.push(u>>>1),this.dts=d[0]<<30|d[1]<<15|d[2],s-=10}if(1===this.escrFlag){var l=[],h=[];u=r.readUint8(),l.push(u>>>3&7),l.push(3&u),u=r.readUint16(),l.push(u>>>13),l.push(3&u),u=r.readUint16(),l.push(u>>>13),h.push(3&u),u=r.readUint8(),h.push(u>>>1),this.escr=300*(l[0]<<30|l[1]<<28|l[2]<<15|l[3]<<13|l[4])+(h[0]<<7|h[1]),s-=6}if(1===this.esRateFlag&&(u=r.readUint24(),this.esRate=u>>>1&4194303,s-=3),1===this.dsmFlag)throw new Error("not support DSM_trick_mode");if(1===this.additionalFlag&&(u=r.readUint8(),this.additionalCopyInfo=127&u,s-=1),1===this.crcFlag&&(this.pesCRC=r.readUint16(),s-=2),1===this.extensionFlag)throw new Error("not support extension");s>0&&r.skip(s),this.ES=new e.ES(r,this.type,t.slice(1))}},{key:"ES",value:function(t,n,r){var a=void 0;if("video"===n){if(1!==(a=t.readUint32())&&(t.back(4),1!==(a=t.readUint24())))throw new Error("h264 nal header parse failed");t.skip(2),this.sps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(7!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint24())?(r=!1,e.back(4)):(e.back(4),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t),this.pps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(8!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint16())?(r=!1,e.back(3)):(e.back(3),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t);var u=void 0;if(this.sps.length?(this.info=new o.default(new Uint8Array(this.sps)).readSPS(),u=t.readUint24()):0===(u=t.readUint24())&&(u=t.readUint8()),1!==u)throw new Error("h264 convert to avcc error");var s=e.Merge(t,r);this.buffer=(0,i.default)(Uint8Array,t.writeUint32(s.byteLength),s)}else{if("audio"!==n)throw"ES "+n+" is not supported";if((a=t.readUint16())>>>4!=4095)throw new Error("aac ES parse Error");this.id=0==(a>>>3&1)?"MPEG-4":"MPEG-2",this.layer=a>>>1&3,this.absent=1&a,a=t.readUint16(),this.audioObjectType=1+(a>>>14&3),this.profile=this.audioObjectType-1,this.frequencyIndex=a>>>10&15,this.frequence=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][this.frequencyIndex],this.channel=a>>>6&7,this.frameLength=(3&a)<<11|t.readUint16()>>>5,this.audioConfig=e.getAudioConfig(this.audioObjectType,this.channel,this.frequencyIndex),t.skip(1),this.buffer=e.Merge(t,r)}}},{key:"TSDT",value:function(){return{}}},{key:"CAT",value:function(e,t){this.tableID=e.readUint8();var n=e.readUint16();this.sectionIndicator=n>>>7,this.sectionLength=4095&n,e.skip(2),n=e.readUint8(),this.version=n>>>3,this.currentNextIndicator=1&n,this.sectionNumber=e.readUint8(),this.lastSectionNumber=e.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=6?(e=5,i=new Array(4),a=n-3):(e=2,i=new Array(2),a=n):-1!==r.indexOf("android")?(e=2,i=new Array(2),a=n):(e=5,i=new Array(4),n>=6?a=n-3:(1===t&&(e=2,i=new Array(2)),a=n)),i[0]=e<<3,i[0]|=(14&n)>>1,i[1]=(1&n)<<7,i[1]|=t<<3,5===e&&(i[1]|=(14&a)>>1,i[2]=(1&a)<<7,i[2]|=8,i[3]=0),i}}]),e}();f.PATSpace=[],t.default=f,e.exports=t.default},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(28));e.exports=r.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,i.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"sourceBuffer",error:e})}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen"),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"mediaSource",error:e})})}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return r(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.mediaSource.readyState&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){e.exports=n(7)},function(e,t,n){"use strict";var r=o(n(8)),i=o(n(9)),a=o(n(5));function o(e){return e&&e.__esModule?e:{default:e}}r.default.install("hlsplayer",function(){var e=this,t=r.default.sniffer,n=r.default.util,o=e.config.preloadTime||15;if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&a.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var u=e.start,s=void 0;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.config.url;t&&(s=new i.default(t),e.mse=s.mse,e.hls=s,e.download=function(){s.download()},s.m3u8.once("ready",function(){if("live"===s.type){n.addClass(e.root,"xgplayer-is-live");var t=n.createDom("xg-live","正在直播",{},"xgplayer-live");e.controls.appendChild(t);var r=setInterval(function(){if(e.paused&&e.buffered.length)for(var t=0,n=e.buffered.length;te.currentTime){e.currentTime=e.buffered.start(t),clearInterval(r);break}},200)}else clearTimeout(s.m3u8.timer)}),u.call(e,s.mse.url))};var f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.currentTime,n=e.getBufferedRange();tr){e.currentTime=t.start(i)+.1;break}}else s.seek()}),e.once("destroy",function(){clearTimeout(s.m3u8.timer)})}})},function(e,t){e.exports=Player},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n=r&&u.end<=i&&(u.downloaded=!0)}}}]),e}();t.default=h,e.exports=t.default},function(e,t,n){"use strict";var r=n(11),i=n(19),a=n(20),o=n(21);(e.exports=function(e,t){var n,a,u,s,f;return arguments.length<2||"string"!=typeof e?(s=t,t=e,e=null):s=arguments[2],null==e?(n=u=!0,a=!1):(n=o.call(e,"c"),a=o.call(e,"e"),u=o.call(e,"w")),f={value:t,configurable:n,enumerable:a,writable:u},s?r(i(s),f):f}).gs=function(e,t,n){var u,s,f,c;return"string"!=typeof e?(f=n,n=t,t=e,e=null):f=arguments[3],null==t?t=void 0:a(t)?null==n?n=void 0:a(n)||(f=n,n=void 0):(f=t,t=n=void 0),null==e?(u=!0,s=!1):(u=o.call(e,"c"),s=o.call(e,"e")),c={get:t,set:n,configurable:u,enumerable:s},f?r(i(f),c):c}},function(e,t,n){"use strict";e.exports=n(12)()?Object.assign:n(13)},function(e,t,n){"use strict";e.exports=function(){var e,t=Object.assign;return"function"==typeof t&&(t(e={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),e.foo+e.bar+e.trzy==="razdwatrzy")}},function(e,t,n){"use strict";var r=n(14),i=n(18),a=Math.max;e.exports=function(e,t){var n,o,u,s=a(arguments.length,2);for(e=Object(i(e)),u=function(r){try{e[r]=t[r]}catch(e){n||(n=e)}},o=1;o-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.url,r=t.method,i=void 0===r?"GET":r,a=t.type,o=void 0===a?"arraybuffer":a,u=t.data,s=void 0===u?{}:u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new Promise(function(e,t){var r=new window.XMLHttpRequest,a=i.toUpperCase(),u=[];for(var f in o&&(r.responseType=o),s)u.push("k="+s[f]);if("GET"===a)r.open(a,n+"?"+u.join("&")),r.send();else{if("post"!==a)throw new Error("xhr "+a+" is not supported");r.open(a,n),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(u.join("&"))}r.onload=function(){200===r.status||206===r.status?e(r):t(r)},r.onerror=function(){t(r)}})},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n-1&&("video"===i.body.type?1===i.header.payload?((a=[]).push(i),t.push(a)):0===a.length?t.push([i]):a.push(i):"audio"===i.body.type&&(1===i.header.payload?((o=[]).push(i),t.push(o)):0===o.length?t.push([i]):o.push(i)));return t}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){for(var t=0,n=arguments.length,r=Array(n>1?n-1:0),i=1;i0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint24",value:function(){return e.readByte(this.dataview,3)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}},{key:"length",get:function(){return this.buffer.byteLength}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw"not supported for readBody 8";r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=i,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;ne?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),n=this.word>>>32-t;return e>32&&window.console.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?n<>>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(e){var t,n=8,r=8;for(t=0;t>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new i.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new i.default,r=8,a=e.mvhd(t.duration),o=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),a,o,u,s),n.buffer}},{key:"mvhd",value:function(t){var n=new i.default;t*=9e4;var r=Math.floor(t/(a+1)),o=Math.floor(t%(a+1)),u=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,0,1,95,144,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n.write(e.size(8+u.length),e.type("mvhd"),new Uint8Array(u)),n.buffer}},{key:"videoTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:1,duration:t.duration,timescale:9e4,width:t.width,height:t.height,type:"video"}),o=e.mdia({type:"video",timescale:9e4,duration:t.duration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"audioTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:2,duration:t.duration,timescale:9e4,width:0,height:0,type:"audio"}),o=e.mdia({type:"audio",timescale:9e4,duration:t.duration,channelCount:t.channelCount,samplerate:t.samplerate,audioConfig:t.audioConfig});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"tkhd",value:function(t){var n=new i.default,r=t.id,o=t.duration*t.timescale,u=t.width,s=t.height,f=t.type,c=Math.floor(o/(a+1)),d=Math.floor(o%(a+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,u>>8&255,255&u,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new i.default,r=t.duration,a=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new i.default,r=8,a=e.mdhd(t.timescale),o=e.hdlr(t.type),u=e.minf(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),a,o,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new i.default;n*=t;var o=Math.floor(n/(a+1)),u=Math.floor(n%(a+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,o>>24,o>>16&255,o>>8&255,255&o,u>>24,u>>16&255,u>>8&255,255&u,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new i.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new i.default,r=8,a="video"===t.type?e.vmhd():e.smhd(),o=e.dinf(),u=e.stbl(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),a,o,u),n.buffer}},{key:"vmhd",value:function(){var t=new i.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new i.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new i.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new i.default,r=8,a=e.stsd(t),o=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[a,o,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),a,o,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new i.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),a=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+a.byteLength),e.type("mp4a"),r,a),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new i.default,a=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+a.byteLength),e.type("esds"),a),r.buffer}},{key:"avc1",value:function(t){var n=new i.default,r=t.sps,a=t.pps,o=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([a.length>>>8&255,255&a.length]).concat(a)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t){var n=new i.default,r=i.default.writeUint32(9e4*t);return n.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),r,e.trex(1),e.trex(2)),n.buffer}},{key:"trex",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new i.default,r=8,a=e.mfhd(),o=e.traf(t);return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),a,o),n.buffer}},{key:"mfhd",value:function(){var t=new i.default,n=i.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new i.default,r=8,a=e.tfhd(t.id),o=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),a,o,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new i.default,r=i.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new i.default,r=Math.floor(t/(a+1)),o=Math.floor(t%(a+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),i.default.writeUint32(r),i.default.writeUint32(o)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,a=1===r?16:12,o=new i.default,u=i.default.writeUint32(t.samples.length),s=i.default.writeUint32(96+a*t.samples.length+n);return o.write(e.size(20+a*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){o.write(i.default.writeUint32(e.duration)),o.write(i.default.writeUint32(e.size)),1===r?(o.write(i.default.writeUint32(e.key?33554432:16842752)),o.write(i.default.writeUint32(e.offset))):o.write(i.default.writeUint32(16777216))}),o.buffer}},{key:"sdtp",value:function(t){var n=new i.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new i.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();o.sequence=1,t.default=o,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,o.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"sourceBuffer",error:e})}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen"),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"mediaSource",error:e})})}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return i(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.mediaSource.readyState&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r,i=n(10),a=(r=i)&&r.__esModule?r:{default:r};e.exports=a.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>>15,this.payload=t>>>14&1,this.priority=t>>>13&1,this.pid=8191&t,t=e.readUint8(),this.scrambling=t>>6&3,this.adaptation=t>>4&3,this.continuity=15&t,this.packet=0===this.pid?"PAT":"MEDIA"}},{key:"Payload",value:function(t,n){var r=n.header.pid,i=void 0;switch(r){case 0:i=new e.PAT(t);break;case 1:i=new e.CAT(t);break;case 2:i=new e.TSDT(t);break;case 8191:i=!1;break;default:if(e.PATSpace.some(function(e){return e.pid===r}))i=new e.PMT(t,n);else{var a=e.PMTSpace?e.PMTSpace.filter(function(e){return e.pid===r}):[];i=!!a.length&&new e.Media(t,n,s[a[0].streamType][0])}}return i}},{key:"PAT",value:function(t){var n=t.readUint8();t.skip(n),n=t.readUint8(),this.tabelID=n,n=t.readUint16(),this.error=n>>>7,this.zero=n>>>6&1,this.sectionLength=4095&n,this.streamID=t.readUint16(),this.current=1&t.readUint8(),this.sectionNumber=t.readUint8(),this.lastSectionNumber=t.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=4&&(this.crc32=t.readUint32())}},{key:"PMT",value:function(t,n){var r=this;n.header.packet="PMT";var i=t.readUint8();t.skip(i),i=t.readUint8(),this.tableID=i,i=t.readUint16(),this.sectionLength=4095&i,this.program=t.readUint16(),this.current=1&t.readUint8(),this.order=t.readUint8(),this.lastOrder=t.readUint8(),this.PCR_PID=8191&t.readUint16(),this.programLength=4095&t.readUint16();for(var a=(this.sectionLength-13)/5,o=[],u=0;u=4&&(this.crc32=t.readUint32())}},{key:"Media",value:function(e,t,n){var r=t.header;if(this.start=e.position,this.type=n,3===r.adaptation&&(this.adaptationLength=e.readUint8(),this.adaptationLength>0)){var i=e.readUint8();this.discontinue=i>>>7,this.access=i>>>6&1,this.priority=i>>>5&1,this.PCR=i>>>4&1,this.OPCR=i>>>3&1,this.splicePoint=i>>>2&1,this.transportPrivate=i>>>1&1,this.adaptationField=1&i;var o=e.position;if(1===this.PCR&&(this.programClockBase=e.readUint32()<<1,i=e.readUint16(),this.programClockBase|=i>>>15,this.programClockExtension=511&i),1===this.OPCR&&(this.originProgramClockBase=e.readUint32()<<1,i=e.readUint16(),this.originProgramClockBase+=i>>>15,this.originProgramClockExtension=511&i),1===this.splicePoint&&(this.spliceCountdown=e.readUint8()),1===this.transportPrivate)for(var u=e.readUint8(),s=[],f=0;f>>6&1,p=d>>>5&1;1===d>>>7&&(d=e.readUint16(),this.ltwValid=d>>>15,this.ltwOffset=61439&d),1===h&&(d=e.readUint24(),this.piecewiseRate=4194303&d),1===p&&(d=e.readInt8(),this.spliceType=d>>>4,this.dtsNextAU1=d>>>1&7,this.marker1=1&d,d=e.readUint16(),this.dtsNextAU2=d>>>1,this.marker2=1&d,d=e.readUint16(),this.dtsNextAU3=d),e.skip(c-1-(e.position-l))}var v=this.adaptationLength-1-(e.position-o);e.skip(v)}this.buffer=new a.default(e.buffer.slice(e.position))}},{key:"PES",value:function(t){var n=t[0],r=n.body.buffer,i=r.readUint24();if(this.header=n.header,1!==i)throw new Error("this is not pes packet");var a=r.readUint8();a>=224&&a<=239&&(this.type="video"),a>=192&&a<=223&&(this.type="audio");var o=r.readUint16();if(this.packetLength=o,"video"!==this.type&&"audio"!==this.type)throw new Error("format is not supported");var u=r.readUint8();if(2!==u>>>6)throw new Error("error when parse pes header");u=r.readUint8(),this.ptsDTSFlag=u>>>6,this.escrFlag=u>>>5&1,this.esRateFlag=u>>>4&1,this.dsmFlag=u>>>3&1,this.additionalFlag=u>>>2&1,this.crcFlag=u>>>1&1,this.extensionFlag=1&u,this.pesHeaderLength=r.readUint8();var s=this.pesHeaderLength;if(2===this.ptsDTSFlag){var f=[];u=r.readUint8(),f.push(u>>>1&7),u=r.readUint16(),f.push(u>>>1),u=r.readUint16(),f.push(u>>>1),this.pts=f[0]<<30|f[1]<<15|f[2],s-=5,"video"===this.type&&(this.dts=this.pts)}if(3===this.ptsDTSFlag){var c=[];u=r.readUint8(),c.push(u>>>1&7),u=r.readUint16(),c.push(u>>>1),u=r.readUint16(),c.push(u>>>1),this.pts=c[0]<<30|c[1]<<15|c[2];var d=[];u=r.readUint8(),d.push(u>>>1&7),u=r.readUint16(),d.push(u>>>1),u=r.readUint16(),d.push(u>>>1),this.dts=d[0]<<30|d[1]<<15|d[2],s-=10}if(1===this.escrFlag){var l=[],h=[];u=r.readUint8(),l.push(u>>>3&7),l.push(3&u),u=r.readUint16(),l.push(u>>>13),l.push(3&u),u=r.readUint16(),l.push(u>>>13),h.push(3&u),u=r.readUint8(),h.push(u>>>1),this.escr=300*(l[0]<<30|l[1]<<28|l[2]<<15|l[3]<<13|l[4])+(h[0]<<7|h[1]),s-=6}if(1===this.esRateFlag&&(u=r.readUint24(),this.esRate=u>>>1&4194303,s-=3),1===this.dsmFlag)throw new Error("not support DSM_trick_mode");if(1===this.additionalFlag&&(u=r.readUint8(),this.additionalCopyInfo=127&u,s-=1),1===this.crcFlag&&(this.pesCRC=r.readUint16(),s-=2),1===this.extensionFlag)throw new Error("not support extension");s>0&&r.skip(s),this.ES=new e.ES(r,this.type,t.slice(1))}},{key:"ES",value:function(t,n,r){var a=void 0;if("video"===n){if(1!==(a=t.readUint32())&&(t.back(4),1!==(a=t.readUint24())))throw new Error("h264 nal header parse failed");t.skip(2),this.sps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(7!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint24())?(r=!1,e.back(4)):(e.back(4),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t),this.pps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(8!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint16())?(r=!1,e.back(3)):(e.back(3),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t);var u=void 0;if(this.sps.length?(this.info=new o.default(new Uint8Array(this.sps)).readSPS(),u=t.readUint24()):0===(u=t.readUint24())&&(u=t.readUint8()),1!==u)throw new Error("h264 convert to avcc error");var s=e.Merge(t,r);this.buffer=(0,i.default)(Uint8Array,t.writeUint32(s.byteLength),s)}else{if("audio"!==n)throw"ES "+n+" is not supported";if((a=t.readUint16())>>>4!=4095)throw new Error("aac ES parse Error");this.id=0==(a>>>3&1)?"MPEG-4":"MPEG-2",this.layer=a>>>1&3,this.absent=1&a,a=t.readUint16(),this.audioObjectType=1+(a>>>14&3),this.profile=this.audioObjectType-1,this.frequencyIndex=a>>>10&15,this.frequence=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][this.frequencyIndex],this.channel=a>>>6&7,this.frameLength=(3&a)<<11|t.readUint16()>>>5,this.audioConfig=e.getAudioConfig(this.audioObjectType,this.channel,this.frequencyIndex),t.skip(1),this.buffer=e.Merge(t,r)}}},{key:"TSDT",value:function(){return{}}},{key:"CAT",value:function(e,t){this.tableID=e.readUint8();var n=e.readUint16();this.sectionIndicator=n>>>7,this.sectionLength=4095&n,e.skip(2),n=e.readUint8(),this.version=n>>>3,this.currentNextIndicator=1&n,this.sectionNumber=e.readUint8(),this.lastSectionNumber=e.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=6?(e=5,i=new Array(4),a=n-3):(e=2,i=new Array(2),a=n):-1!==r.indexOf("android")?(e=2,i=new Array(2),a=n):(e=5,i=new Array(4),n>=6?a=n-3:(1===t&&(e=2,i=new Array(2)),a=n)),i[0]=e<<3,i[0]|=(14&n)>>1,i[1]=(1&n)<<7,i[1]|=t<<3,5===e&&(i[1]|=(14&a)>>1,i[2]=(1&a)<<7,i[2]|=8,i[3]=0),i}}]),e}();f.PATSpace=[],t.default=f,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new o.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new o.default,r=8,i=e.mvhd(t.duration),a=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),i,a,u,s),n.buffer}},{key:"mvhd",value:function(t){var n=new o.default;t*=9e4;var r=Math.floor(t/(u+1)),i=Math.floor(t%(u+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,0,1,95,144,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n.write(e.size(8+a.length),e.type("mvhd"),new Uint8Array(a)),n.buffer}},{key:"videoTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:1,duration:t.duration,timescale:9e4,width:t.width,height:t.height,type:"video"}),a=e.mdia({type:"video",timescale:9e4,duration:t.duration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"audioTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:2,duration:t.duration,timescale:9e4,width:0,height:0,type:"audio"}),a=e.mdia({type:"audio",timescale:9e4,duration:t.duration,channelCount:t.channelCount,samplerate:t.samplerate,audioConfig:t.audioConfig});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"tkhd",value:function(t){var n=new o.default,r=t.id,i=t.duration*t.timescale,a=t.width,s=t.height,f=t.type,c=Math.floor(i/(u+1)),d=Math.floor(i%(u+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new o.default,r=t.duration,i=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new o.default,r=8,i=e.mdhd(t.timescale),a=e.hdlr(t.type),u=e.minf(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),i,a,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new o.default;n*=t;var i=Math.floor(n/(u+1)),a=Math.floor(n%(u+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new o.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new o.default,r=8,i="video"===t.type?e.vmhd():e.smhd(),a=e.dinf(),u=e.stbl(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),i,a,u),n.buffer}},{key:"vmhd",value:function(){var t=new o.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new o.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new o.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new o.default,r=8,i=e.stsd(t),a=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[i,a,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),i,a,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new o.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),i=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+i.byteLength),e.type("mp4a"),r,i),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new o.default,i=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+i.byteLength),e.type("esds"),i),r.buffer}},{key:"avc1",value:function(t){var n=new o.default,r=t.sps,i=t.pps,a=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([i.length>>>8&255,255&i.length]).concat(i)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t){var n=new o.default,r=o.default.writeUint32(9e4*t);return n.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),r,e.trex(1),e.trex(2)),n.buffer}},{key:"trex",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new o.default,r=8,i=e.mfhd(),a=e.traf(t);return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),i,a),n.buffer}},{key:"mfhd",value:function(){var t=new o.default,n=o.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new o.default,r=8,i=e.tfhd(t.id),a=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),i,a,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new o.default,r=o.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new o.default,r=Math.floor(t/(u+1)),i=Math.floor(t%(u+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),o.default.writeUint32(r),o.default.writeUint32(i)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,i=1===r?16:12,a=new o.default,u=o.default.writeUint32(t.samples.length),s=o.default.writeUint32(96+i*t.samples.length+n);return a.write(e.size(20+i*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){a.write(o.default.writeUint32(e.duration)),a.write(o.default.writeUint32(e.size)),1===r?(a.write(o.default.writeUint32(e.key?33554432:16842752)),a.write(o.default.writeUint32(e.offset))):a.write(o.default.writeUint32(16777216))}),a.buffer}},{key:"sdtp",value:function(t){var n=new o.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new o.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();s.sequence=1,t.default=s,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;ne?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),n=this.word>>>32-t;return e>32&&window.console.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?n<>>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(e){var t,n=8,r=8;for(t=0;t0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint24",value:function(){return e.readByte(this.dataview,3)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}},{key:"length",get:function(){return this.buffer.byteLength}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw"not supported for readBody 8";r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=i,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){for(var t=0,n=arguments.length,r=Array(n>1?n-1:0),i=1;i-1&&("video"===a.body.type?1===a.header.payload?((o=[]).push(a),n.push(o)):0===o.length?n.push([a]):o.push(a):"audio"===a.body.type&&(1===a.header.payload?((u=[]).push(a),n.push(u)):0===u.length?n.push([a]):u.push(a)));return n}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.url,r=t.method,i=void 0===r?"GET":r,a=t.type,o=void 0===a?"arraybuffer":a,u=t.data,s=void 0===u?{}:u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new Promise(function(e,t){var r=new window.XMLHttpRequest,a=i.toUpperCase(),u=[];for(var f in o&&(r.responseType=o),s)u.push("k="+s[f]);if("GET"===a)r.open(a,n+"?"+u.join("&")),r.send();else{if("post"!==a)throw new Error("xhr "+a+" is not supported");r.open(a,n),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(u.join("&"))}r.onload=function(){200===r.status||206===r.status?e(r):t(r)},r.onerror=function(){t(r)}})},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n-1}},function(e,t,n){"use strict";var r="razdwatrzy";e.exports=function(){return"function"==typeof r.contains&&(!0===r.contains("dwa")&&!1===r.contains("foo"))}},function(e,t,n){"use strict";e.exports=n(16)()?String.prototype.contains:n(15)},function(e,t,n){"use strict";e.exports=function(e){return"function"==typeof e}},function(e,t,n){"use strict";var r=n(0),i=Array.prototype.forEach,a=Object.create;e.exports=function(e){var t=a(null);return i.call(arguments,function(e){r(e)&&function(e,t){var n;for(n in e)t[n]=e[n]}(Object(e),t)}),t}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){if(!r(e))throw new TypeError("Cannot use null or undefined");return e}},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";var r=n(0),i=Object.keys;e.exports=function(e){return i(r(e)?Object(e):e)}},function(e,t,n){"use strict";e.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},function(e,t,n){"use strict";e.exports=n(23)()?Object.keys:n(22)},function(e,t,n){"use strict";var r=n(24),i=n(20),a=Math.max;e.exports=function(e,t){var n,o,u,s=a(arguments.length,2);for(e=Object(i(e)),u=function(r){try{e[r]=t[r]}catch(e){n||(n=e)}},o=1;o=r&&u.end<=i&&(u.downloaded=!0)}}}]),e}();t.default=h,e.exports=t.default},function(e,t){e.exports=Player},function(e,t,n){"use strict";var r=o(n(30)),i=o(n(29)),a=o(n(2));function o(e){return e&&e.__esModule?e:{default:e}}r.default.install("hlsplayer",function(){var e=this,t=r.default.sniffer,n=r.default.util,o=e.config.preloadTime||15;if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&a.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var u=e.start,s=void 0;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.config.url;t&&(s=new i.default(t),e.mse=s.mse,e.hls=s,e.download=function(){s.download()},s.m3u8.once("ready",function(){if("live"===s.type){n.addClass(e.root,"xgplayer-is-live");var t=n.createDom("xg-live","正在直播",{},"xgplayer-live");e.controls.appendChild(t);var r=setInterval(function(){if(e.paused&&e.buffered.length)for(var t=0,n=e.buffered.length;te.currentTime){e.currentTime=e.buffered.start(t),clearInterval(r);break}},200)}else clearTimeout(s.m3u8.timer)}),u.call(e,s.mse.url))};var f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.currentTime,n=e.getBufferedRange();tr){e.currentTime=t.start(i)+.1;break}}else s.seek()}),e.once("destroy",function(){clearTimeout(s.m3u8.timer)})}})},function(e,t,n){e.exports=n(31)}]); \ No newline at end of file diff --git a/packages/xgplayer-hls/dist/index.js b/packages/xgplayer-hls/dist/index.js index 55cfa046c..330a334b7 100644 --- a/packages/xgplayer-hls/dist/index.js +++ b/packages/xgplayer-hls/dist/index.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("xgplayer")):"function"==typeof define&&define.amd?define(["xgplayer"],t):"object"==typeof exports?exports["xgplayer-hls"]=t(require("xgplayer")):e["xgplayer-hls"]=t(e.xgplayer)}(window,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";var r,i,a,o,u,s,f,c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=n(10),l=n(24),h=Function.prototype.apply,p=Function.prototype.call,v=Object.create,y=Object.defineProperty,b=Object.defineProperties,w=Object.prototype.hasOwnProperty,g={configurable:!0,enumerable:!1,writable:!0};u={on:r=function(e,t){var n;return l(t),w.call(this,"__ee__")?n=this.__ee__:(n=g.value=v(null),y(this,"__ee__",g),g.value=null),n[e]?"object"===c(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t,this},once:i=function(e,t){var n,i;return l(t),i=this,r.call(this,e,n=function(){a.call(i,e,n),h.call(t,this,arguments)}),n.__eeOnceListener__=t,this},off:a=function(e,t){var n,r,i,a;if(l(t),!w.call(this,"__ee__"))return this;if(!(n=this.__ee__)[e])return this;if("object"===(void 0===(r=n[e])?"undefined":c(r)))for(a=0;i=r[a];++a)i!==t&&i.__eeOnceListener__!==t||(2===r.length?n[e]=r[a?0:1]:r.splice(a,1));else r!==t&&r.__eeOnceListener__!==t||delete n[e];return this},emit:o=function(e){var t,n,r,i,a;if(w.call(this,"__ee__")&&(i=this.__ee__[e]))if("object"===(void 0===i?"undefined":c(i))){for(n=arguments.length,a=new Array(n-1),t=1;t>>15,this.payload=t>>>14&1,this.priority=t>>>13&1,this.pid=8191&t,t=e.readUint8(),this.scrambling=t>>6&3,this.adaptation=t>>4&3,this.continuity=15&t,this.packet=0===this.pid?"PAT":"MEDIA"}},{key:"Payload",value:function(t,n){var r=n.header.pid,i=void 0;switch(r){case 0:i=new e.PAT(t);break;case 1:i=new e.CAT(t);break;case 2:i=new e.TSDT(t);break;case 8191:i=!1;break;default:if(e.PATSpace.some(function(e){return e.pid===r}))i=new e.PMT(t,n);else{var a=e.PMTSpace?e.PMTSpace.filter(function(e){return e.pid===r}):[];i=!!a.length&&new e.Media(t,n,s[a[0].streamType][0])}}return i}},{key:"PAT",value:function(t){var n=t.readUint8();t.skip(n),n=t.readUint8(),this.tabelID=n,n=t.readUint16(),this.error=n>>>7,this.zero=n>>>6&1,this.sectionLength=4095&n,this.streamID=t.readUint16(),this.current=1&t.readUint8(),this.sectionNumber=t.readUint8(),this.lastSectionNumber=t.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=4&&(this.crc32=t.readUint32())}},{key:"PMT",value:function(t,n){var r=this;n.header.packet="PMT";var i=t.readUint8();t.skip(i),i=t.readUint8(),this.tableID=i,i=t.readUint16(),this.sectionLength=4095&i,this.program=t.readUint16(),this.current=1&t.readUint8(),this.order=t.readUint8(),this.lastOrder=t.readUint8(),this.PCR_PID=8191&t.readUint16(),this.programLength=4095&t.readUint16();for(var a=(this.sectionLength-13)/5,o=[],u=0;u=4&&(this.crc32=t.readUint32())}},{key:"Media",value:function(e,t,n){var r=t.header;if(this.start=e.position,this.type=n,3===r.adaptation&&(this.adaptationLength=e.readUint8(),this.adaptationLength>0)){var i=e.readUint8();this.discontinue=i>>>7,this.access=i>>>6&1,this.priority=i>>>5&1,this.PCR=i>>>4&1,this.OPCR=i>>>3&1,this.splicePoint=i>>>2&1,this.transportPrivate=i>>>1&1,this.adaptationField=1&i;var o=e.position;if(1===this.PCR&&(this.programClockBase=e.readUint32()<<1,i=e.readUint16(),this.programClockBase|=i>>>15,this.programClockExtension=511&i),1===this.OPCR&&(this.originProgramClockBase=e.readUint32()<<1,i=e.readUint16(),this.originProgramClockBase+=i>>>15,this.originProgramClockExtension=511&i),1===this.splicePoint&&(this.spliceCountdown=e.readUint8()),1===this.transportPrivate)for(var u=e.readUint8(),s=[],f=0;f>>6&1,p=d>>>5&1;1===d>>>7&&(d=e.readUint16(),this.ltwValid=d>>>15,this.ltwOffset=61439&d),1===h&&(d=e.readUint24(),this.piecewiseRate=4194303&d),1===p&&(d=e.readInt8(),this.spliceType=d>>>4,this.dtsNextAU1=d>>>1&7,this.marker1=1&d,d=e.readUint16(),this.dtsNextAU2=d>>>1,this.marker2=1&d,d=e.readUint16(),this.dtsNextAU3=d),e.skip(c-1-(e.position-l))}var v=this.adaptationLength-1-(e.position-o);e.skip(v)}this.buffer=new a.default(e.buffer.slice(e.position))}},{key:"PES",value:function(t){var n=t[0],r=n.body.buffer,i=r.readUint24();if(this.header=n.header,1!==i)throw new Error("this is not pes packet");var a=r.readUint8();a>=224&&a<=239&&(this.type="video"),a>=192&&a<=223&&(this.type="audio");var o=r.readUint16();if(this.packetLength=o,"video"!==this.type&&"audio"!==this.type)throw new Error("format is not supported");var u=r.readUint8();if(2!==u>>>6)throw new Error("error when parse pes header");u=r.readUint8(),this.ptsDTSFlag=u>>>6,this.escrFlag=u>>>5&1,this.esRateFlag=u>>>4&1,this.dsmFlag=u>>>3&1,this.additionalFlag=u>>>2&1,this.crcFlag=u>>>1&1,this.extensionFlag=1&u,this.pesHeaderLength=r.readUint8();var s=this.pesHeaderLength;if(2===this.ptsDTSFlag){var f=[];u=r.readUint8(),f.push(u>>>1&7),u=r.readUint16(),f.push(u>>>1),u=r.readUint16(),f.push(u>>>1),this.pts=f[0]<<30|f[1]<<15|f[2],s-=5,"video"===this.type&&(this.dts=this.pts)}if(3===this.ptsDTSFlag){var c=[];u=r.readUint8(),c.push(u>>>1&7),u=r.readUint16(),c.push(u>>>1),u=r.readUint16(),c.push(u>>>1),this.pts=c[0]<<30|c[1]<<15|c[2];var d=[];u=r.readUint8(),d.push(u>>>1&7),u=r.readUint16(),d.push(u>>>1),u=r.readUint16(),d.push(u>>>1),this.dts=d[0]<<30|d[1]<<15|d[2],s-=10}if(1===this.escrFlag){var l=[],h=[];u=r.readUint8(),l.push(u>>>3&7),l.push(3&u),u=r.readUint16(),l.push(u>>>13),l.push(3&u),u=r.readUint16(),l.push(u>>>13),h.push(3&u),u=r.readUint8(),h.push(u>>>1),this.escr=300*(l[0]<<30|l[1]<<28|l[2]<<15|l[3]<<13|l[4])+(h[0]<<7|h[1]),s-=6}if(1===this.esRateFlag&&(u=r.readUint24(),this.esRate=u>>>1&4194303,s-=3),1===this.dsmFlag)throw new Error("not support DSM_trick_mode");if(1===this.additionalFlag&&(u=r.readUint8(),this.additionalCopyInfo=127&u,s-=1),1===this.crcFlag&&(this.pesCRC=r.readUint16(),s-=2),1===this.extensionFlag)throw new Error("not support extension");s>0&&r.skip(s),this.ES=new e.ES(r,this.type,t.slice(1))}},{key:"ES",value:function(t,n,r){var a=void 0;if("video"===n){if(1!==(a=t.readUint32())&&(t.back(4),1!==(a=t.readUint24())))throw new Error("h264 nal header parse failed");t.skip(2),this.sps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(7!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint24())?(r=!1,e.back(4)):(e.back(4),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t),this.pps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(8!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint16())?(r=!1,e.back(3)):(e.back(3),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t);var u=void 0;if(this.sps.length?(this.info=new o.default(new Uint8Array(this.sps)).readSPS(),u=t.readUint24()):0===(u=t.readUint24())&&(u=t.readUint8()),1!==u)throw new Error("h264 convert to avcc error");var s=e.Merge(t,r);this.buffer=(0,i.default)(Uint8Array,t.writeUint32(s.byteLength),s)}else{if("audio"!==n)throw"ES "+n+" is not supported";if((a=t.readUint16())>>>4!=4095)throw new Error("aac ES parse Error");this.id=0==(a>>>3&1)?"MPEG-4":"MPEG-2",this.layer=a>>>1&3,this.absent=1&a,a=t.readUint16(),this.audioObjectType=1+(a>>>14&3),this.profile=this.audioObjectType-1,this.frequencyIndex=a>>>10&15,this.frequence=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][this.frequencyIndex],this.channel=a>>>6&7,this.frameLength=(3&a)<<11|t.readUint16()>>>5,this.audioConfig=e.getAudioConfig(this.audioObjectType,this.channel,this.frequencyIndex),t.skip(1),this.buffer=e.Merge(t,r)}}},{key:"TSDT",value:function(){return{}}},{key:"CAT",value:function(e,t){this.tableID=e.readUint8();var n=e.readUint16();this.sectionIndicator=n>>>7,this.sectionLength=4095&n,e.skip(2),n=e.readUint8(),this.version=n>>>3,this.currentNextIndicator=1&n,this.sectionNumber=e.readUint8(),this.lastSectionNumber=e.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=6?(e=5,i=new Array(4),a=n-3):(e=2,i=new Array(2),a=n):-1!==r.indexOf("android")?(e=2,i=new Array(2),a=n):(e=5,i=new Array(4),n>=6?a=n-3:(1===t&&(e=2,i=new Array(2)),a=n)),i[0]=e<<3,i[0]|=(14&n)>>1,i[1]=(1&n)<<7,i[1]|=t<<3,5===e&&(i[1]|=(14&a)>>1,i[2]=(1&a)<<7,i[2]|=8,i[3]=0),i}}]),e}();f.PATSpace=[],t.default=f,e.exports=t.default},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(28));e.exports=r.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,i.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"sourceBuffer",error:e})}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen"),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"mediaSource",error:e})})}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return r(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.mediaSource.readyState&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){e.exports=n(7)},function(e,t,n){"use strict";var r=o(n(8)),i=o(n(9)),a=o(n(5));function o(e){return e&&e.__esModule?e:{default:e}}r.default.install("hlsplayer",function(){var e=this,t=r.default.sniffer,n=r.default.util,o=e.config.preloadTime||15;if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&a.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var u=e.start,s=void 0;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.config.url;t&&(s=new i.default(t),e.mse=s.mse,e.hls=s,e.download=function(){s.download()},s.m3u8.once("ready",function(){if("live"===s.type){n.addClass(e.root,"xgplayer-is-live");var t=n.createDom("xg-live","正在直播",{},"xgplayer-live");e.controls.appendChild(t);var r=setInterval(function(){if(e.paused&&e.buffered.length)for(var t=0,n=e.buffered.length;te.currentTime){e.currentTime=e.buffered.start(t),clearInterval(r);break}},200)}else clearTimeout(s.m3u8.timer)}),u.call(e,s.mse.url))};var f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.currentTime,n=e.getBufferedRange();tr){e.currentTime=t.start(i)+.1;break}}else s.seek()}),e.once("destroy",function(){clearTimeout(s.m3u8.timer)})}})},function(t,n){t.exports=e},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n=r&&u.end<=i&&(u.downloaded=!0)}}}]),e}();t.default=h,e.exports=t.default},function(e,t,n){"use strict";var r=n(11),i=n(19),a=n(20),o=n(21);(e.exports=function(e,t){var n,a,u,s,f;return arguments.length<2||"string"!=typeof e?(s=t,t=e,e=null):s=arguments[2],null==e?(n=u=!0,a=!1):(n=o.call(e,"c"),a=o.call(e,"e"),u=o.call(e,"w")),f={value:t,configurable:n,enumerable:a,writable:u},s?r(i(s),f):f}).gs=function(e,t,n){var u,s,f,c;return"string"!=typeof e?(f=n,n=t,t=e,e=null):f=arguments[3],null==t?t=void 0:a(t)?null==n?n=void 0:a(n)||(f=n,n=void 0):(f=t,t=n=void 0),null==e?(u=!0,s=!1):(u=o.call(e,"c"),s=o.call(e,"e")),c={get:t,set:n,configurable:u,enumerable:s},f?r(i(f),c):c}},function(e,t,n){"use strict";e.exports=n(12)()?Object.assign:n(13)},function(e,t,n){"use strict";e.exports=function(){var e,t=Object.assign;return"function"==typeof t&&(t(e={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),e.foo+e.bar+e.trzy==="razdwatrzy")}},function(e,t,n){"use strict";var r=n(14),i=n(18),a=Math.max;e.exports=function(e,t){var n,o,u,s=a(arguments.length,2);for(e=Object(i(e)),u=function(r){try{e[r]=t[r]}catch(e){n||(n=e)}},o=1;o-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.url,r=t.method,i=void 0===r?"GET":r,a=t.type,o=void 0===a?"arraybuffer":a,u=t.data,s=void 0===u?{}:u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new Promise(function(e,t){var r=new window.XMLHttpRequest,a=i.toUpperCase(),u=[];for(var f in o&&(r.responseType=o),s)u.push("k="+s[f]);if("GET"===a)r.open(a,n+"?"+u.join("&")),r.send();else{if("post"!==a)throw new Error("xhr "+a+" is not supported");r.open(a,n),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(u.join("&"))}r.onload=function(){200===r.status||206===r.status?e(r):t(r)},r.onerror=function(){t(r)}})},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n-1&&("video"===i.body.type?1===i.header.payload?((a=[]).push(i),t.push(a)):0===a.length?t.push([i]):a.push(i):"audio"===i.body.type&&(1===i.header.payload?((o=[]).push(i),t.push(o)):0===o.length?t.push([i]):o.push(i)));return t}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){for(var t=0,n=arguments.length,r=Array(n>1?n-1:0),i=1;i0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint24",value:function(){return e.readByte(this.dataview,3)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}},{key:"length",get:function(){return this.buffer.byteLength}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw"not supported for readBody 8";r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=i,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;ne?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),n=this.word>>>32-t;return e>32&&window.console.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?n<>>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(e){var t,n=8,r=8;for(t=0;t>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new i.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new i.default,r=8,a=e.mvhd(t.duration),o=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),a,o,u,s),n.buffer}},{key:"mvhd",value:function(t){var n=new i.default;t*=9e4;var r=Math.floor(t/(a+1)),o=Math.floor(t%(a+1)),u=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,0,1,95,144,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n.write(e.size(8+u.length),e.type("mvhd"),new Uint8Array(u)),n.buffer}},{key:"videoTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:1,duration:t.duration,timescale:9e4,width:t.width,height:t.height,type:"video"}),o=e.mdia({type:"video",timescale:9e4,duration:t.duration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"audioTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:2,duration:t.duration,timescale:9e4,width:0,height:0,type:"audio"}),o=e.mdia({type:"audio",timescale:9e4,duration:t.duration,channelCount:t.channelCount,samplerate:t.samplerate,audioConfig:t.audioConfig});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"tkhd",value:function(t){var n=new i.default,r=t.id,o=t.duration*t.timescale,u=t.width,s=t.height,f=t.type,c=Math.floor(o/(a+1)),d=Math.floor(o%(a+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,u>>8&255,255&u,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new i.default,r=t.duration,a=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new i.default,r=8,a=e.mdhd(t.timescale),o=e.hdlr(t.type),u=e.minf(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),a,o,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new i.default;n*=t;var o=Math.floor(n/(a+1)),u=Math.floor(n%(a+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,o>>24,o>>16&255,o>>8&255,255&o,u>>24,u>>16&255,u>>8&255,255&u,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new i.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new i.default,r=8,a="video"===t.type?e.vmhd():e.smhd(),o=e.dinf(),u=e.stbl(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),a,o,u),n.buffer}},{key:"vmhd",value:function(){var t=new i.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new i.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new i.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new i.default,r=8,a=e.stsd(t),o=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[a,o,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),a,o,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new i.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),a=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+a.byteLength),e.type("mp4a"),r,a),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new i.default,a=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+a.byteLength),e.type("esds"),a),r.buffer}},{key:"avc1",value:function(t){var n=new i.default,r=t.sps,a=t.pps,o=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([a.length>>>8&255,255&a.length]).concat(a)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t){var n=new i.default,r=i.default.writeUint32(9e4*t);return n.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),r,e.trex(1),e.trex(2)),n.buffer}},{key:"trex",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new i.default,r=8,a=e.mfhd(),o=e.traf(t);return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),a,o),n.buffer}},{key:"mfhd",value:function(){var t=new i.default,n=i.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new i.default,r=8,a=e.tfhd(t.id),o=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),a,o,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new i.default,r=i.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new i.default,r=Math.floor(t/(a+1)),o=Math.floor(t%(a+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),i.default.writeUint32(r),i.default.writeUint32(o)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,a=1===r?16:12,o=new i.default,u=i.default.writeUint32(t.samples.length),s=i.default.writeUint32(96+a*t.samples.length+n);return o.write(e.size(20+a*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){o.write(i.default.writeUint32(e.duration)),o.write(i.default.writeUint32(e.size)),1===r?(o.write(i.default.writeUint32(e.key?33554432:16842752)),o.write(i.default.writeUint32(e.offset))):o.write(i.default.writeUint32(16777216))}),o.buffer}},{key:"sdtp",value:function(t){var n=new i.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new i.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();o.sequence=1,t.default=o,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,o.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"sourceBuffer",error:e})}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen"),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",{type:"mediaSource",error:e})})}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return i(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.mediaSource.readyState&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r,i=n(10),a=(r=i)&&r.__esModule?r:{default:r};e.exports=a.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>>15,this.payload=t>>>14&1,this.priority=t>>>13&1,this.pid=8191&t,t=e.readUint8(),this.scrambling=t>>6&3,this.adaptation=t>>4&3,this.continuity=15&t,this.packet=0===this.pid?"PAT":"MEDIA"}},{key:"Payload",value:function(t,n){var r=n.header.pid,i=void 0;switch(r){case 0:i=new e.PAT(t);break;case 1:i=new e.CAT(t);break;case 2:i=new e.TSDT(t);break;case 8191:i=!1;break;default:if(e.PATSpace.some(function(e){return e.pid===r}))i=new e.PMT(t,n);else{var a=e.PMTSpace?e.PMTSpace.filter(function(e){return e.pid===r}):[];i=!!a.length&&new e.Media(t,n,s[a[0].streamType][0])}}return i}},{key:"PAT",value:function(t){var n=t.readUint8();t.skip(n),n=t.readUint8(),this.tabelID=n,n=t.readUint16(),this.error=n>>>7,this.zero=n>>>6&1,this.sectionLength=4095&n,this.streamID=t.readUint16(),this.current=1&t.readUint8(),this.sectionNumber=t.readUint8(),this.lastSectionNumber=t.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=4&&(this.crc32=t.readUint32())}},{key:"PMT",value:function(t,n){var r=this;n.header.packet="PMT";var i=t.readUint8();t.skip(i),i=t.readUint8(),this.tableID=i,i=t.readUint16(),this.sectionLength=4095&i,this.program=t.readUint16(),this.current=1&t.readUint8(),this.order=t.readUint8(),this.lastOrder=t.readUint8(),this.PCR_PID=8191&t.readUint16(),this.programLength=4095&t.readUint16();for(var a=(this.sectionLength-13)/5,o=[],u=0;u=4&&(this.crc32=t.readUint32())}},{key:"Media",value:function(e,t,n){var r=t.header;if(this.start=e.position,this.type=n,3===r.adaptation&&(this.adaptationLength=e.readUint8(),this.adaptationLength>0)){var i=e.readUint8();this.discontinue=i>>>7,this.access=i>>>6&1,this.priority=i>>>5&1,this.PCR=i>>>4&1,this.OPCR=i>>>3&1,this.splicePoint=i>>>2&1,this.transportPrivate=i>>>1&1,this.adaptationField=1&i;var o=e.position;if(1===this.PCR&&(this.programClockBase=e.readUint32()<<1,i=e.readUint16(),this.programClockBase|=i>>>15,this.programClockExtension=511&i),1===this.OPCR&&(this.originProgramClockBase=e.readUint32()<<1,i=e.readUint16(),this.originProgramClockBase+=i>>>15,this.originProgramClockExtension=511&i),1===this.splicePoint&&(this.spliceCountdown=e.readUint8()),1===this.transportPrivate)for(var u=e.readUint8(),s=[],f=0;f>>6&1,p=d>>>5&1;1===d>>>7&&(d=e.readUint16(),this.ltwValid=d>>>15,this.ltwOffset=61439&d),1===h&&(d=e.readUint24(),this.piecewiseRate=4194303&d),1===p&&(d=e.readInt8(),this.spliceType=d>>>4,this.dtsNextAU1=d>>>1&7,this.marker1=1&d,d=e.readUint16(),this.dtsNextAU2=d>>>1,this.marker2=1&d,d=e.readUint16(),this.dtsNextAU3=d),e.skip(c-1-(e.position-l))}var v=this.adaptationLength-1-(e.position-o);e.skip(v)}this.buffer=new a.default(e.buffer.slice(e.position))}},{key:"PES",value:function(t){var n=t[0],r=n.body.buffer,i=r.readUint24();if(this.header=n.header,1!==i)throw new Error("this is not pes packet");var a=r.readUint8();a>=224&&a<=239&&(this.type="video"),a>=192&&a<=223&&(this.type="audio");var o=r.readUint16();if(this.packetLength=o,"video"!==this.type&&"audio"!==this.type)throw new Error("format is not supported");var u=r.readUint8();if(2!==u>>>6)throw new Error("error when parse pes header");u=r.readUint8(),this.ptsDTSFlag=u>>>6,this.escrFlag=u>>>5&1,this.esRateFlag=u>>>4&1,this.dsmFlag=u>>>3&1,this.additionalFlag=u>>>2&1,this.crcFlag=u>>>1&1,this.extensionFlag=1&u,this.pesHeaderLength=r.readUint8();var s=this.pesHeaderLength;if(2===this.ptsDTSFlag){var f=[];u=r.readUint8(),f.push(u>>>1&7),u=r.readUint16(),f.push(u>>>1),u=r.readUint16(),f.push(u>>>1),this.pts=f[0]<<30|f[1]<<15|f[2],s-=5,"video"===this.type&&(this.dts=this.pts)}if(3===this.ptsDTSFlag){var c=[];u=r.readUint8(),c.push(u>>>1&7),u=r.readUint16(),c.push(u>>>1),u=r.readUint16(),c.push(u>>>1),this.pts=c[0]<<30|c[1]<<15|c[2];var d=[];u=r.readUint8(),d.push(u>>>1&7),u=r.readUint16(),d.push(u>>>1),u=r.readUint16(),d.push(u>>>1),this.dts=d[0]<<30|d[1]<<15|d[2],s-=10}if(1===this.escrFlag){var l=[],h=[];u=r.readUint8(),l.push(u>>>3&7),l.push(3&u),u=r.readUint16(),l.push(u>>>13),l.push(3&u),u=r.readUint16(),l.push(u>>>13),h.push(3&u),u=r.readUint8(),h.push(u>>>1),this.escr=300*(l[0]<<30|l[1]<<28|l[2]<<15|l[3]<<13|l[4])+(h[0]<<7|h[1]),s-=6}if(1===this.esRateFlag&&(u=r.readUint24(),this.esRate=u>>>1&4194303,s-=3),1===this.dsmFlag)throw new Error("not support DSM_trick_mode");if(1===this.additionalFlag&&(u=r.readUint8(),this.additionalCopyInfo=127&u,s-=1),1===this.crcFlag&&(this.pesCRC=r.readUint16(),s-=2),1===this.extensionFlag)throw new Error("not support extension");s>0&&r.skip(s),this.ES=new e.ES(r,this.type,t.slice(1))}},{key:"ES",value:function(t,n,r){var a=void 0;if("video"===n){if(1!==(a=t.readUint32())&&(t.back(4),1!==(a=t.readUint24())))throw new Error("h264 nal header parse failed");t.skip(2),this.sps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(7!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint24())?(r=!1,e.back(4)):(e.back(4),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t),this.pps=function(e){var t=[],n=void 0,r=!0,i=!1;if(1===e.readUint32())do{if(n=e.readUint8(),!i){if(8!=(31&n)){r=!1,e.back(5);break}i=!0}0!==n?t.push(n):1===(n=e.readUint16())?(r=!1,e.back(3)):(e.back(3),t.push(e.readUint8()))}while(r);else e.back(4);return t}(t);var u=void 0;if(this.sps.length?(this.info=new o.default(new Uint8Array(this.sps)).readSPS(),u=t.readUint24()):0===(u=t.readUint24())&&(u=t.readUint8()),1!==u)throw new Error("h264 convert to avcc error");var s=e.Merge(t,r);this.buffer=(0,i.default)(Uint8Array,t.writeUint32(s.byteLength),s)}else{if("audio"!==n)throw"ES "+n+" is not supported";if((a=t.readUint16())>>>4!=4095)throw new Error("aac ES parse Error");this.id=0==(a>>>3&1)?"MPEG-4":"MPEG-2",this.layer=a>>>1&3,this.absent=1&a,a=t.readUint16(),this.audioObjectType=1+(a>>>14&3),this.profile=this.audioObjectType-1,this.frequencyIndex=a>>>10&15,this.frequence=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][this.frequencyIndex],this.channel=a>>>6&7,this.frameLength=(3&a)<<11|t.readUint16()>>>5,this.audioConfig=e.getAudioConfig(this.audioObjectType,this.channel,this.frequencyIndex),t.skip(1),this.buffer=e.Merge(t,r)}}},{key:"TSDT",value:function(){return{}}},{key:"CAT",value:function(e,t){this.tableID=e.readUint8();var n=e.readUint16();this.sectionIndicator=n>>>7,this.sectionLength=4095&n,e.skip(2),n=e.readUint8(),this.version=n>>>3,this.currentNextIndicator=1&n,this.sectionNumber=e.readUint8(),this.lastSectionNumber=e.readUint8();for(var r=(this.sectionLength-9)/4,i=[],a=0;a=6?(e=5,i=new Array(4),a=n-3):(e=2,i=new Array(2),a=n):-1!==r.indexOf("android")?(e=2,i=new Array(2),a=n):(e=5,i=new Array(4),n>=6?a=n-3:(1===t&&(e=2,i=new Array(2)),a=n)),i[0]=e<<3,i[0]|=(14&n)>>1,i[1]=(1&n)<<7,i[1]|=t<<3,5===e&&(i[1]|=(14&a)>>1,i[2]=(1&a)<<7,i[2]|=8,i[3]=0),i}}]),e}();f.PATSpace=[],t.default=f,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new o.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new o.default,r=8,i=e.mvhd(t.duration),a=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),i,a,u,s),n.buffer}},{key:"mvhd",value:function(t){var n=new o.default;t*=9e4;var r=Math.floor(t/(u+1)),i=Math.floor(t%(u+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,0,1,95,144,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return n.write(e.size(8+a.length),e.type("mvhd"),new Uint8Array(a)),n.buffer}},{key:"videoTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:1,duration:t.duration,timescale:9e4,width:t.width,height:t.height,type:"video"}),a=e.mdia({type:"video",timescale:9e4,duration:t.duration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"audioTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:2,duration:t.duration,timescale:9e4,width:0,height:0,type:"audio"}),a=e.mdia({type:"audio",timescale:9e4,duration:t.duration,channelCount:t.channelCount,samplerate:t.samplerate,audioConfig:t.audioConfig});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"tkhd",value:function(t){var n=new o.default,r=t.id,i=t.duration*t.timescale,a=t.width,s=t.height,f=t.type,c=Math.floor(i/(u+1)),d=Math.floor(i%(u+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new o.default,r=t.duration,i=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new o.default,r=8,i=e.mdhd(t.timescale),a=e.hdlr(t.type),u=e.minf(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),i,a,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new o.default;n*=t;var i=Math.floor(n/(u+1)),a=Math.floor(n%(u+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new o.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new o.default,r=8,i="video"===t.type?e.vmhd():e.smhd(),a=e.dinf(),u=e.stbl(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),i,a,u),n.buffer}},{key:"vmhd",value:function(){var t=new o.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new o.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new o.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new o.default,r=8,i=e.stsd(t),a=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[i,a,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),i,a,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new o.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),i=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+i.byteLength),e.type("mp4a"),r,i),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new o.default,i=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+i.byteLength),e.type("esds"),i),r.buffer}},{key:"avc1",value:function(t){var n=new o.default,r=t.sps,i=t.pps,a=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([i.length>>>8&255,255&i.length]).concat(i)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t){var n=new o.default,r=o.default.writeUint32(9e4*t);return n.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),r,e.trex(1),e.trex(2)),n.buffer}},{key:"trex",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new o.default,r=8,i=e.mfhd(),a=e.traf(t);return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),i,a),n.buffer}},{key:"mfhd",value:function(){var t=new o.default,n=o.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new o.default,r=8,i=e.tfhd(t.id),a=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),i,a,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new o.default,r=o.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new o.default,r=Math.floor(t/(u+1)),i=Math.floor(t%(u+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),o.default.writeUint32(r),o.default.writeUint32(i)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,i=1===r?16:12,a=new o.default,u=o.default.writeUint32(t.samples.length),s=o.default.writeUint32(96+i*t.samples.length+n);return a.write(e.size(20+i*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){a.write(o.default.writeUint32(e.duration)),a.write(o.default.writeUint32(e.size)),1===r?(a.write(o.default.writeUint32(e.key?33554432:16842752)),a.write(o.default.writeUint32(e.offset))):a.write(o.default.writeUint32(16777216))}),a.buffer}},{key:"sdtp",value:function(t){var n=new o.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new o.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();s.sequence=1,t.default=s,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;ne?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),n=this.word>>>32-t;return e>32&&window.console.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?n<>>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(e){var t,n=8,r=8;for(t=0;t0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint24",value:function(){return e.readByte(this.dataview,3)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}},{key:"length",get:function(){return this.buffer.byteLength}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw"not supported for readBody 8";r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=i,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){for(var t=0,n=arguments.length,r=Array(n>1?n-1:0),i=1;i-1&&("video"===a.body.type?1===a.header.payload?((o=[]).push(a),n.push(o)):0===o.length?n.push([a]):o.push(a):"audio"===a.body.type&&(1===a.header.payload?((u=[]).push(a),n.push(u)):0===u.length?n.push([a]):u.push(a)));return n}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.url,r=t.method,i=void 0===r?"GET":r,a=t.type,o=void 0===a?"arraybuffer":a,u=t.data,s=void 0===u?{}:u;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new Promise(function(e,t){var r=new window.XMLHttpRequest,a=i.toUpperCase(),u=[];for(var f in o&&(r.responseType=o),s)u.push("k="+s[f]);if("GET"===a)r.open(a,n+"?"+u.join("&")),r.send();else{if("post"!==a)throw new Error("xhr "+a+" is not supported");r.open(a,n),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(u.join("&"))}r.onload=function(){200===r.status||206===r.status?e(r):t(r)},r.onerror=function(){t(r)}})},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n-1}},function(e,t,n){"use strict";var r="razdwatrzy";e.exports=function(){return"function"==typeof r.contains&&(!0===r.contains("dwa")&&!1===r.contains("foo"))}},function(e,t,n){"use strict";e.exports=n(16)()?String.prototype.contains:n(15)},function(e,t,n){"use strict";e.exports=function(e){return"function"==typeof e}},function(e,t,n){"use strict";var r=n(0),i=Array.prototype.forEach,a=Object.create;e.exports=function(e){var t=a(null);return i.call(arguments,function(e){r(e)&&function(e,t){var n;for(n in e)t[n]=e[n]}(Object(e),t)}),t}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e){if(!r(e))throw new TypeError("Cannot use null or undefined");return e}},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";var r=n(0),i=Object.keys;e.exports=function(e){return i(r(e)?Object(e):e)}},function(e,t,n){"use strict";e.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},function(e,t,n){"use strict";e.exports=n(23)()?Object.keys:n(22)},function(e,t,n){"use strict";var r=n(24),i=n(20),a=Math.max;e.exports=function(e,t){var n,o,u,s=a(arguments.length,2);for(e=Object(i(e)),u=function(r){try{e[r]=t[r]}catch(e){n||(n=e)}},o=1;o=r&&u.end<=i&&(u.downloaded=!0)}}}]),e}();t.default=h,e.exports=t.default},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=o(n(30)),i=o(n(29)),a=o(n(2));function o(e){return e&&e.__esModule?e:{default:e}}r.default.install("hlsplayer",function(){var e=this,t=r.default.sniffer,n=r.default.util,o=e.config.preloadTime||15;if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&a.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var u=e.start,s=void 0;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.config.url;t&&(s=new i.default(t),e.mse=s.mse,e.hls=s,e.download=function(){s.download()},s.m3u8.once("ready",function(){if("live"===s.type){n.addClass(e.root,"xgplayer-is-live");var t=n.createDom("xg-live","正在直播",{},"xgplayer-live");e.controls.appendChild(t);var r=setInterval(function(){if(e.paused&&e.buffered.length)for(var t=0,n=e.buffered.length;te.currentTime){e.currentTime=e.buffered.start(t),clearInterval(r);break}},200)}else clearTimeout(s.m3u8.timer)}),u.call(e,s.mse.url))};var f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e.currentTime,n=e.getBufferedRange();tr){e.currentTime=t.start(i)+.1;break}}else s.seek()}),e.once("destroy",function(){clearTimeout(s.m3u8.timer)})}})},function(e,t,n){e.exports=n(31)}])}); \ No newline at end of file diff --git a/packages/xgplayer-mp4/browser/index.js b/packages/xgplayer-mp4/browser/index.js index eb79df025..fcba4b83c 100644 --- a/packages/xgplayer-mp4/browser/index.js +++ b/packages/xgplayer-mp4/browser/index.js @@ -1 +1 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=36)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw new i.default("parse","",{line:73,handle:"[Stream] readByte",msg:"not supported for readBody 8"});r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t,n){"use strict";var r=n(39)("wks"),i=n(18),a=n(2).Symbol,o="function"==typeof a;(e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)("Symbol."+e))}).store=r},function(e,t,n){"use strict";var r=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(e,t,n){"use strict";var r=n(6);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function(e){return"object"===(void 0===e?"undefined":r(e))?null!==e:"function"==typeof e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){return e&&e.__esModule?e:{default:e}}(n(32)),i=n(79);var a=function(e){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r.version=i.version;var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));return o.url=a,o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.default.Errors),t}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";var r=n(9);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){"use strict";e.exports=!n(21)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";var r={}.toString;e.exports=function(e){return r.call(e).slice(8,-1)}},function(e,t,n){"use strict";var r=n(5),i=n(40),a=n(41),o=Object.defineProperty;t.f=n(10)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){"use strict";var r,i,a,o,u,s,f,c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=n(62),l=n(76),h=Function.prototype.apply,v=Function.prototype.call,p=Object.create,m=Object.defineProperty,y=Object.defineProperties,b=Object.prototype.hasOwnProperty,w={configurable:!0,enumerable:!1,writable:!0};u={on:r=function(e,t){var n;return l(t),b.call(this,"__ee__")?n=this.__ee__:(n=w.value=p(null),m(this,"__ee__",w),w.value=null),n[e]?"object"===c(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t,this},once:i=function(e,t){var n,i;return l(t),i=this,r.call(this,e,n=function(){a.call(i,e,n),h.call(t,this,arguments)}),n.__eeOnceListener__=t,this},off:a=function(e,t){var n,r,i,a;if(l(t),!b.call(this,"__ee__"))return this;if(!(n=this.__ee__)[e])return this;if("object"===(void 0===(r=n[e])?"undefined":c(r)))for(a=0;i=r[a];++a)i!==t&&i.__eeOnceListener__!==t||(2===r.length?n[e]=r[a?0:1]:r.splice(a,1));else r!==t&&r.__eeOnceListener__!==t||delete n[e];return this},emit:o=function(e){var t,n,r,i,a;if(b.call(this,"__ee__")&&(i=this.__ee__[e]))if("object"===(void 0===i?"undefined":c(i))){for(n=arguments.length,a=new Array(n-1),t=1;t0?i(r(e),9007199254740991):0}},function(e,t,n){"use strict";var r=Math.ceil,i=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?i:r)(e)}},function(e,t,n){"use strict";var r,i,a,o=n(8),u=n(49),s=n(50),f=n(22),c=n(2),d=c.process,l=c.setImmediate,h=c.clearImmediate,v=c.MessageChannel,p=c.Dispatch,m=0,y={},b=function(){var e=+this;if(y.hasOwnProperty(e)){var t=y[e];delete y[e],t()}},w=function(e){b.call(e.data)};l&&h||(l=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return y[++m]=function(){u("function"==typeof e?e:Function(e),t)},r(m),m},h=function(e){delete y[e]},"process"==n(11)(d)?r=function(e){d.nextTick(o(b,e,1))}:p&&p.now?r=function(e){p.now(o(b,e,1))}:v?(a=(i=new v).port2,i.port1.onmessage=w,r=o(a.postMessage,a,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScripts?(r=function(e){c.postMessage(e+"","*")},c.addEventListener("message",w,!1)):r="onreadystatechange"in f("script")?function(e){s.appendChild(f("script")).onreadystatechange=function(){s.removeChild(this),b.call(e)}}:function(e){setTimeout(o(b,e,1),0)}),e.exports={set:l,clear:h}},function(e,t,n){"use strict";var r=n(9);e.exports.f=function(e){return new function(e){var t,n;this.promise=new e(function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r}),this.resolve=r(t),this.reject=r(n)}(e)}},function(e,t,n){"use strict";var r=n(2).navigator;e.exports=r&&r.userAgent||""},function(e,t,n){"use strict";e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t){e.exports=Player},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(80));e.exports=r.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.currentTime;e.timer&&clearTimeout(e.timer),r=Math.max(r,e.currentTime),e.timer=setTimeout(function(){e.mp4.seek(r+.1*n).then(function(t){if(t){var n=e.mse;n.updating=!0,n.appendBuffer(t),n.once("updateend",function(){n.updating=!1})}},function(){n<10&&setTimeout(function(){t(n+1)},2e3)})},50)},m=function(t){var n=new a.default(t),r=void 0;return new Promise(function(t,i){n.once("moovReady",function(){(r=new o.default).on("sourceopen",function(){r.appendBuffer(n.packMeta()),r.once("updateend",p.bind(e))}),r.on("error",function(e){i(e)}),t([n,r])}),n.on("error",function(e){i(e)})})};if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&o.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var y=e.start;if(!v.call(e))return!1;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s;m(n).then(function(t){var n=t[0],r=t[1];y.call(e,r.url),e.mp4=n,e.mse=r,n.on("error",function(t){f(e,t)})},function(t){y.call(e,n),f(e,t)}),e.once("canplay",function(){if("safari"===t.browser&&e.buffered){var n=e.buffered.start(0);e.currentTime=n+.1}})},e.switchURL=function(n){var r=new a.default(n),i=e.mp4;r.on("moovReady",function(){i.timeRage;var n=e.currentTime,a=i.timeRage.find(function(e){return e[0]-n>2})[0],o=e.getBufferedRange()[1];o-a>0&&"safari"!==t.browser&&e.mse.removeBuffer(a,o),e.mp4=r,e.mse.appendBuffer(r.packMeta())}),r.on("error",function(t){f(e,t)})},e.on("timeupdate",function(){var t=e.mse,n=e.mp4;if(t&&!t.updating&&n.canDownload){var r=n.timeRage,i=e.getBufferedRange(),a=e.currentTime+d;if(i[1]-a>0)return;r.every(function(e,t){var r=(e[0]+e[1])/2;return 0===i[1]?(p(5),!1):!(r>i[1]&&!n.bufferCache.has(t))||void p(0,r)}),function(e,t){if(t.meta.endTime-e.currentTime<2){var n=e.getBufferedRange();e.currentTime-n[1]<.1&&e.mse.endOfStream()}}(e,n)}}),e.on("seeking",function(){var t=e.buffered,n=!1,r=e.currentTime;if(u.default.clear(),t.length){for(var i=0,a=t.length;i=t.start(i)&&r<=t.end(i)){n=!0;break}n||p(0,r)}else p(0,e.currentTime)}),e.on("pause",function(){u.default.clear()}),e.on("playing",function(){l&&clearTimeout(l)}),e.on("waiting",function(){var t=e.mp4;if(t&&t.meta){var n=e.getBufferedRange(),r=t.meta.videoDuration;r-e.currentTime<.5&&r-n[1]<.5?e.mse.endOfStream():(p(0,n[1]+1),l=setTimeout(function(){for(var t=e.buffered,n=void 0,r=0,i=t.length;r=e.currentTime){e.currentTime=n;break}},1500))}}),e._replay=function(){u.default.clear(),e.mp4.bufferCache.clear(),m(e.mp4.url).then(function(t){var n=t[0],r=t[1];e.src=r.url,e.mp4=n,e.mse=r,e.currentTime=0,e.play()},function(t){f(e,t)})}}}else e.emit("error",new r("other",e.config.vid))})},function(e,t,n){"use strict";var r,i,a,o,u=n(16),s=n(2),f=n(8),c=n(17),d=n(19),l=n(6),h=n(9),v=n(43),p=n(44),m=n(48),y=n(28).set,b=n(51)(),w=n(29),g=n(52),_=n(30),x=n(53),U=s.TypeError,k=s.process,S=k&&k.versions,B=S&&S.v8||"",M=s.Promise,T="process"==c(k),O=function(){},j=i=w.f,E=!!function(){try{var e=M.resolve(1),t=(e.constructor={})[n(3)("species")]=function(e){e(O,O)};return(T||"function"==typeof PromiseRejectionEvent)&&e.then(O)instanceof t&&0!==B.indexOf("6.6")&&-1===_.indexOf("Chrome/66")}catch(e){}}(),z=function(e){var t;return!(!l(e)||"function"!=typeof(t=e.then))&&t},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;b(function(){for(var r=e._v,i=1==e._s,a=0,o=function(t){var n,a,o,u=i?t.ok:t.fail,s=t.resolve,f=t.reject,c=t.domain;try{u?(i||(2==e._h&&D(e),e._h=1),!0===u?n=r:(c&&c.enter(),n=u(r),c&&(c.exit(),o=!0)),n===t.promise?f(U("Promise-chain cycle")):(a=z(n))?a.call(n,s,f):s(n)):f(r)}catch(e){c&&!o&&c.exit(),f(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&P(e)})}},P=function(e){y.call(s,function(){var t,n,r,i=e._v,a=A(e);if(a&&(t=g(function(){T?k.emit("unhandledRejection",i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error("Unhandled promise rejection",i)}),e._h=T||A(e)?2:1),e._a=void 0,a&&t.e)throw t.v})},A=function(e){return 1!==e._h&&0===(e._a||e._c).length},D=function(e){y.call(s,function(){var t;T?k.emit("rejectionHandled",e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},L=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),C(t,!0))},R=function e(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw U("Promise can't be resolved itself");(n=z(t))?b(function(){var i={_w:r,_d:!1};try{n.call(t,f(e,i,1),f(L,i,1))}catch(e){L.call(i,e)}}):(r._v=t,r._s=1,C(r,!1))}catch(e){L.call({_w:r,_d:!1},e)}}};E||(M=function(e){v(this,M,"Promise","_h"),h(e),r.call(this);try{e(f(R,this,1),f(L,this,1))}catch(e){L.call(this,e)}},(r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=n(54)(M.prototype,{then:function(e,t){var n=j(m(this,M));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=T?k.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),a=function(){var e=new r;this.promise=e,this.resolve=f(R,e,1),this.reject=f(L,e,1)},w.f=j=function(e){return e===M||e===o?new a(e):i(e)}),d(d.G+d.W+d.F*!E,{Promise:M}),n(55)(M,"Promise"),n(56)("Promise"),o=n(4).Promise,d(d.S+d.F*!E,"Promise",{reject:function(e){var t=j(this);return(0,t.reject)(e),t.promise}}),d(d.S+d.F*(u||!E),"Promise",{resolve:function(e){return x(u&&this===o?M:this,e)}}),d(d.S+d.F*!(E&&n(57)(function(e){M.all(e).catch(O)})),"Promise",{all:function(e){var t=this,n=j(t),r=n.resolve,i=n.reject,a=g(function(){var n=[],a=0,o=1;p(e,!1,function(e){var u=a++,s=!1;n.push(void 0),o++,t.resolve(e).then(function(e){s||(s=!0,n[u]=e,--o||r(n))},i)}),--o||r(n)});return a.e&&i(a.v),n.promise},race:function(e){var t=this,n=j(t),r=n.reject,i=g(function(){p(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}})},function(e,t,n){"use strict";var r=n(4),i=n(2),a=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(e.exports=function(e,t){return a[e]||(a[e]=void 0!==t?t:{})})("versions",[]).push({version:r.version,mode:n(16)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(e,t,n){"use strict";e.exports=!n(10)&&!n(21)(function(){return 7!=Object.defineProperty(n(22)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";var r=n(6);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t,n){"use strict";e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t,n){"use strict";var r=n(8),i=n(45),a=n(46),o=n(5),u=n(26),s=n(47),f={},c={},d=e.exports=function(e,t,n,d,l){var h,v,p,m,y=l?function(){return e}:s(e),b=r(n,d,t?2:1),w=0;if("function"!=typeof y)throw TypeError(e+" is not iterable!");if(a(y)){for(h=u(e.length);h>w;w++)if((m=t?b(o(v=e[w])[0],v[1]):b(e[w]))===f||m===c)return m}else for(p=y.call(e);!(v=p.next()).done;)if((m=i(p,b,v.value,t))===f||m===c)return m};d.BREAK=f,d.RETURN=c},function(e,t,n){"use strict";var r=n(5);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw void 0!==a&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(25),i=n(3)("iterator"),a=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||a[i]===e)}},function(e,t,n){"use strict";var r=n(17),i=n(3)("iterator"),a=n(25);e.exports=n(4).getIteratorMethod=function(e){if(void 0!=e)return e[i]||e["@@iterator"]||a[r(e)]}},function(e,t,n){"use strict";var r=n(5),i=n(9),a=n(3)("species");e.exports=function(e,t){var n,o=r(e).constructor;return void 0===o||void 0==(n=r(o)[a])?t:i(n)}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){"use strict";var r=n(2).document;e.exports=r&&r.documentElement},function(e,t,n){"use strict";var r=n(2),i=n(28).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,u=r.Promise,s="process"==n(11)(o);e.exports=function(){var e,t,n,f=function(){var r,i;for(s&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(s)n=function(){o.nextTick(f)};else if(!a||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var c=u.resolve(void 0);n=function(){c.then(f)}}else n=function(){i.call(r,f)};else{var d=!0,l=document.createTextNode("");new a(f).observe(l,{characterData:!0}),n=function(){l.data=d=!d}}return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){"use strict";e.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},function(e,t,n){"use strict";var r=n(5),i=n(6),a=n(29);e.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=a.f(e);return(0,n.resolve)(t),n.promise}},function(e,t,n){"use strict";var r=n(23);e.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},function(e,t,n){"use strict";var r=n(12).f,i=n(24),a=n(3)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){"use strict";var r=n(2),i=n(12),a=n(10),o=n(3)("species");e.exports=function(e){var t=r[e];a&&t&&!t[o]&&i.f(t,o,{configurable:!0,get:function(){return this}})}},function(e,t,n){"use strict";var r=n(3)("iterator"),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch(e){}return n}},function(e,t,n){"use strict";var r=n(19),i=n(59),a=n(30);r(r.P+r.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(a),"String",{padStart:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0,!0)}})},function(e,t,n){"use strict";var r=n(26),i=n(60),a=n(31);e.exports=function(e,t,n,o){var u=String(a(e)),s=u.length,f=void 0===n?" ":String(n),c=r(t);if(c<=s||""==f)return u;var d=c-s,l=i.call(f,Math.ceil(d/f.length));return l.length>d&&(l=l.slice(0,d)),o?l+u:u+l}},function(e,t,n){"use strict";var r=n(27),i=n(31);e.exports=function(e){var t=String(i(this)),n="",a=r(e);if(a<0||a==1/0)throw RangeError("Count can't be negative");for(;a>0;(a>>>=1)&&(t+=t))1&a&&(n+=t);return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:Math.pow(25,4);!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(0,i.default)(this),this.url=t,this.CHUNK_SIZE=n,this.init(t),this.once("moovReady",this.moovParse.bind(this)),this.cache=new u.default,this.bufferCache=new Set,this.timeRage=[],this.canDownload=!0}return r(e,[{key:"getData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+this.CHUNK_SIZE,r=this;return new Promise(function(i,a){new f.default(e.url,[t,n],i).once("error",function(e){r.emit("error",e)})})}},{key:"moovParse",value:function(){var e=this,t=this,n=this.moovBox,r=c.default.findBox(n,"mvhd"),i=void 0,o=void 0,u=void 0,s=void 0,f=void 0,l=void 0,h=void 0,v=void 0,p=void 0,m=void 0,y=void 0,b=void 0,w=void 0,g=void 0;c.default.findBox(n,"trak").forEach(function(e){var n=c.default.findBox(e,"hdlr"),r=c.default.findBox(e,"mdhd");if(n&&r){var a=c.default.findBox(e,"stsd").subBox[0];if("vide"===n.handleType){var _=c.default.findBox(e,"avcC"),x=c.default.findBox(e,"avc1");i=e,f=r.timescale,_?(u=a.type+"."+c.default.toHex(_.profile,_.profileCompatibility,_.AVCLevelIndication).join(""),h=_.sequence&&_.sequence.map(function(e){return Number("0x"+e)}),v=_.pps&&_.pps.map(function(e){return Number("0x"+e)}),p=_.profile):u=""+a.type,x&&(m=x.width,y=x.height)}if("soun"===n.handleType){o=e;var U=c.default.findBox(e,"esds"),k=c.default.findBox(e,"mp4a"),S=c.default.findBox(e,5);l=r.timescale,s=U?a.type+"."+c.default.toHex(U.subBox[0].subBox[0].typeID)+"."+U.subBox[0].subBox[0].subBox[0].type:""+a.type,S&&S.EScode&&(g=S.EScode.map(function(e){return Number("0x"+e)})),k&&(b=k.channelCount,w=k.sampleRate)}}else t.emit("error",new d.default("parse","",{line:72,handle:"[MP4] moovParse",url:t.url}))}),this.videoTrak=(0,a.default)({},i),this.audioTrak=(0,a.default)({},o);var _=this._boxes.find(function(e){return"mdat"===e.type}),x=c.default.seekTrakDuration(i,f),U=c.default.seekTrakDuration(o,l);this.mdatStart=_.start;var k=this.videoKeyFrames,S=k.length-1;k.forEach(function(t,n){n0&&void 0!==arguments[0]?arguments[0]:"video",t=arguments[1],n=arguments[2],r="video"===e?this.videoTrak:this.audioTrak,i=c.default.findBox(r,"stsc"),a=c.default.findBox(r,"stsz"),o=c.default.findBox(r,"stts"),u=c.default.findBox(r,"stco"),s=c.default.findBox(r,"ctts"),f=this.mdatStart,d=[];if(n=void 0!==n?n:a.entries.length,t instanceof Array)t.forEach(function(e,t){d.push({idx:e,size:a.entries[e],time:c.default.seekSampleTime(o,s,e),offset:c.default.seekSampleOffset(i,u,a,e,f)})});else if(0!==n)for(var l=t;l-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e){return function(e){return!!e&&"object"===(void 0===e?"undefined":r(e))}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===a}(e)}(e)};var a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(function(e){return Array.isArray(e)?[]:{}}(e),e,t):e}function u(e,t,n){return e.concat(t).map(function(e){return o(e,n)})}function s(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||u,n.isMergeableObject=n.isMergeableObject||i;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):function(e,t,n){var r={};return n.isMergeableObject(e)&&Object.keys(e).forEach(function(t){r[t]=o(e[t],n)}),Object.keys(t).forEach(function(i){n.isMergeableObject(t[i])&&e[i]?r[i]=s(e[i],t[i],n):r[i]=o(t[i],n)}),r}(e,t,n):o(t,n)}s.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})};var f=s;t.default=f,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=V(n(0)),i=V(n(33)),a=V(n(1)),o=V(n(81)),u=V(n(82)),s=V(n(83)),f=V(n(84)),c=V(n(85)),d=V(n(86)),l=V(n(87)),h=V(n(88)),v=V(n(89)),p=V(n(90)),m=V(n(91)),y=V(n(92)),b=V(n(93)),w=V(n(94)),g=V(n(95)),_=V(n(96)),x=V(n(97)),U=V(n(98)),k=V(n(99)),S=V(n(100)),B=V(n(101)),M=V(n(102)),T=V(n(103)),O=V(n(104)),j=V(n(105)),E=V(n(106)),z=V(n(107)),C=V(n(108)),P=V(n(109)),A=V(n(110)),D=V(n(111)),L=V(n(112)),R=V(n(113)),F=V(n(114)),I=V(n(115)),N=V(n(116)),q=V(n(117)),K=V(n(118)),H=V(n(119)),G=V(n(120));function V(e){return e&&e.__esModule?e:{default:e}}var W={};function X(e,t,n){var r=e;t.map(function(e,i){r[e]=i==t.length-1?n:r[e]||{},r=r[e]})}X(W,["box","avc1"],V(n(121)).default),X(W,["box","avcC"],G.default),X(W,["box","btrt"],H.default),X(W,["box","co64"],K.default),X(W,["box","ctts"],q.default),X(W,["box","dref"],N.default),X(W,["box","elst"],I.default),X(W,["box","esds"],F.default),X(W,["box","ftyp"],R.default),X(W,["box","hdlr"],L.default),X(W,["box","hmhd"],D.default),X(W,["box","iods"],A.default),X(W,["box","mdat"],P.default),X(W,["box","mdhd"],C.default),X(W,["box","mfhd"],z.default),X(W,["box","mp4a"],E.default),X(W,["box","MP4DecConfigDescrTag"],j.default),X(W,["box","MP4DecSpecificDescrTag"],O.default),X(W,["box","MP4ESDescrTag"],T.default),X(W,["box","mvhd"],M.default),X(W,["box","nmhd"],B.default),X(W,["box","pasp"],S.default),X(W,["box","sbgp"],k.default),X(W,["box","sdtp"],U.default),X(W,["box","SLConfigDescriptor"],x.default),X(W,["box","smhd"],_.default),X(W,["box","stco"],g.default),X(W,["box","stsc"],w.default),X(W,["box","stsd"],b.default),X(W,["box","stsh"],y.default),X(W,["box","stss"],m.default),X(W,["box","stsz"],p.default),X(W,["box","stts"],v.default),X(W,["box","stz2"],h.default),X(W,["box","tfhd"],l.default),X(W,["box","tkhd"],d.default),X(W,["box","traf"],c.default),X(W,["box","trun"],f.default),X(W,["box","udta"],s.default),X(W,["box","url"],u.default),X(W,["box","vmhd"],o.default);t.default=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.buffer=null,this.boxes=[],this.nextBox=null,this.start=0;this.buffer?(0,i.default)(Uint8Array,this.buffer,t):this.buffer=t;var n=t.byteLength;t.position=0;for(var o=new a.default(t);n-o.position>=8;){var u=new r.default;if(u.readHeader(o),u.size-8<=n-o.position)u.readBody(o),this.boxes.push(u);else{if("mdat"!==u.type){this.nextBox=u,o.position-=8;break}u.readBody(o),this.boxes.push(u)}}this.buffer=new Uint8Array(this.buffer.slice(o.position))},e.exports=t.default},function(e){e.exports={name:"xgplayer-mp4",version:"1.0.5",description:"xgplayer plugin for mp4 transform to fmp4",main:"./dist/index.js",scripts:{prepare:"npm run build",build:"webpack --progress --display-chunks -p",watch:"webpack --progress --display-chunks -p --watch"},repository:{type:"git",url:"git@github.com:bytedance/xgplayer.git"},babel:{presets:["es2015"],plugins:["add-module-exports","babel-plugin-bulk-import"]},keywords:["mp4","fmp4","player","video"],author:"yinguohui@bytedance.com",license:"MIT",dependencies:{"babel-loader":"^7.1.4","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-bulk-import":"^1.0.2","babel-preset-es2015":"^6.24.1","concat-typed-array":"^1.0.2",deepmerge:"^2.0.1","event-emitter":"^0.3.5","json-loader":"^0.5.7",webpack:"^4.11.0"},peerDependency:{xgplayer:"^0.1.0"},devDependencies:{"babel-core":"^6.26.3"}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){for(var t=0,n=arguments.length,r=Array(n>1?n-1:0),i=1;i>8,e.readUint16();for(var t=[],n=0;n<9;n++)t.push(e.readUint16()+"."+e.readUint16());this.matrix=t,this.width=e.readUint16()+"."+e.readUint16(),this.height=e.readUint16()+"."+e.readUint16(),delete this.data,delete this.subBox,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stts=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.count=e.readUint32();for(var t=[],n=0,r=this.count;n1){var c=t[this.count-1],d=t[this.count-2];c.first_sample=d.first_sample+d.chunk_count*d.samples_per_chunk,c.chunk_count=0}delete this.subBox,delete this.data,e=null}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stco=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.count=e.readUint32();var t=[];this.entries=t;for(var n=0,r=this.count;n>16;var t=new r.default;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=o(n(0)),i=o(n(1)),a=o(n(15));function o(e){return e&&e.__esModule?e:{default:e}}r.default.mdhd=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),1===this.version?(this.create=e.readUint64(),this.modify=e.readUint64(),this.createTime=(new a.default).setTime(1e3*this.create),this.modifyTime=(new a.default).setTime(1e3*this.modify),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.create=e.readUint32(),this.modify=e.readUint32(),this.createTime=(new a.default).setTime(1e3*this.create),this.modifyTime=(new a.default).setTime(1e3*this.modify),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.language=e.readUint16(),e.readUint16(),delete this.subBox,delete this.data,e=null}},function(e,t,n){"use strict";(function(e){return e&&e.__esModule?e:{default:e}})(n(0)).default.mdat=function(){delete this.subBox}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.iods=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3);for(var t=[],n=e.buffer.byteLength;e.position>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new i.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new i.default,r=8,a=e.mvhd(t.duration,t.timeScale),o=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration,t.timeScale);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),a,o,u,s),n.buffer}},{key:"mvhd",value:function(t,n){var r=new i.default;t*=n;var o=Math.floor(t/(a+1)),u=Math.floor(t%(a+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,o>>24,o>>16&255,o>>8&255,255&o,u>>24,u>>16&255,u>>8&255,255&u,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return r.write(e.size(8+s.length),e.type("mvhd"),new Uint8Array(s)),r.buffer}},{key:"videoTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:1,duration:t.videoDuration,timescale:t.videoTimeScale,width:t.width,height:t.height,type:"video"}),o=e.mdia({type:"video",timescale:t.videoTimeScale,duration:t.videoDuration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"audioTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:2,duration:t.audioDuration,timescale:t.audioTimeScale,width:0,height:0,type:"audio"}),o=e.mdia({type:"audio",timescale:t.audioTimeScale,duration:t.audioDuration,channelCount:t.channelCount,samplerate:t.sampleRate,audioConfig:t.audioConfig});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"tkhd",value:function(t){var n=new i.default,r=t.id,o=t.duration*t.timeScale,u=t.width,s=t.height,f=t.type,c=Math.floor(o/(a+1)),d=Math.floor(o%(a+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,u>>8&255,255&u,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new i.default,r=t.duration,a=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new i.default,r=8,a=e.mdhd(t.timescale),o=e.hdlr(t.type),u=e.minf(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),a,o,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new i.default;n*=t;var o=Math.floor(n/(a+1)),u=Math.floor(n%(a+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,o>>24,o>>16&255,o>>8&255,255&o,u>>24,u>>16&255,u>>8&255,255&u,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new i.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new i.default,r=8,a="video"===t.type?e.vmhd():e.smhd(),o=e.dinf(),u=e.stbl(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),a,o,u),n.buffer}},{key:"vmhd",value:function(){var t=new i.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new i.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new i.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new i.default,r=8,a=e.stsd(t),o=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[a,o,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),a,o,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new i.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),a=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+a.byteLength),e.type("mp4a"),r,a),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new i.default,a=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+a.byteLength),e.type("esds"),a),r.buffer}},{key:"avc1",value:function(t){var n=new i.default,r=t.sps,a=t.pps,o=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([a.length>>>8&255,255&a.length]).concat(a)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t,n){var r=new i.default,a=i.default.writeUint32(t*n);return r.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),a,e.trex(1),e.trex(2)),r.buffer}},{key:"trex",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new i.default,r=8,a=e.mfhd(),o=e.traf(t);return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),a,o),n.buffer}},{key:"mfhd",value:function(){var t=new i.default,n=i.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new i.default,r=8,a=e.tfhd(t.id),o=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),a,o,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new i.default,r=i.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new i.default,r=Math.floor(t/(a+1)),o=Math.floor(t%(a+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),i.default.writeUint32(r),i.default.writeUint32(o)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,a=1===r?16:12,o=new i.default,u=i.default.writeUint32(t.samples.length),s=i.default.writeUint32(96+a*t.samples.length+n);return o.write(e.size(20+a*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){o.write(i.default.writeUint32(e.duration)),o.write(i.default.writeUint32(e.size)),1===r?(o.write(i.default.writeUint32(e.key?33554432:16842752)),o.write(i.default.writeUint32(e.offset))):o.write(i.default.writeUint32(16777216))}),o.buffer}},{key:"sdtp",value:function(t){var n=new i.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new i.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();o.sequence=1,t.default=o,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=document.createElement("a"),i=new Blob([n]),a=document.createEvent("MouseEvents");a.initEvent("click",!1,!1),r.download=t,r.href=URL.createObjectURL(i),r.dispatchEvent(a)},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={findBox:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e.type!==t){if(e&&e.subBox){var i=e.subBox.filter(function(e){return e.type===t});i.length?i.forEach(function(e){return n.push(e)}):e.subBox.forEach(function(e){return r.findBox(e,t,n)})}}else n.push(e);return(n=[].concat(n)).length>1?n:n[0]},padStart:function(e,t,n){for(var r=String(n),i=t>>0,a=Math.ceil(i/r.length),o=[],u=String(e);a--;)o.push(r);return o.join("").substring(0,i-u.length)+u},toHex:function(){for(var e=[],t=arguments.length,n=Array(t),i=0;i0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,i.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.updating=!1,this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",new a.default("mse","",{line:16,handle:"[MSE] constructor sourceopen",msg:e.message}))}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen")}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return r(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.state&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=u,e.exports=t.default}]); \ No newline at end of file +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=125)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw new o.default("parse","",{line:73,handle:"[Stream] readByte",msg:"not supported for readBody 8"});r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t,n){"use strict";var r=n(122)("wks"),i=n(33),a=n(2).Symbol,o="function"==typeof a;(e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)("Symbol."+e))}).store=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=n(19),a=(r=i)&&r.__esModule?r:{default:r},o=n(82);var u=function(e){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r.version=o.version;var a=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));return a.url=i,a}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default.Errors),t}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function(e){return"object"===(void 0===e?"undefined":r(e))?null!==e:"function"==typeof e}},function(e,t,n){"use strict";var r=n(5);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){"use strict";var r=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(e,t,n){"use strict";e.exports=!n(30)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){"use strict";var r=n(9);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r,i=n(81),a=(r=i)&&r.__esModule?r:{default:r};e.exports=a.default},function(e,t){e.exports=Player},function(e,t,n){"use strict";e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){"use strict";var r=n(2).navigator;e.exports=r&&r.userAgent||""},function(e,t,n){"use strict";var r=n(9);e.exports.f=function(e){return new function(e){var t,n;this.promise=new e(function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r}),this.resolve=r(t),this.reject=r(n)}(e)}},function(e,t,n){"use strict";var r,i,a,o=n(10),u=n(112),s=n(111),f=n(29),c=n(2),d=c.process,l=c.setImmediate,h=c.clearImmediate,v=c.MessageChannel,p=c.Dispatch,m=0,y={},b=function(){var e=+this;if(y.hasOwnProperty(e)){var t=y[e];delete y[e],t()}},w=function(e){b.call(e.data)};l&&h||(l=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return y[++m]=function(){u("function"==typeof e?e:Function(e),t)},r(m),m},h=function(e){delete y[e]},"process"==n(15)(d)?r=function(e){d.nextTick(o(b,e,1))}:p&&p.now?r=function(e){p.now(o(b,e,1))}:v?(a=(i=new v).port2,i.port1.onmessage=w,r=o(a.postMessage,a,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScripts?(r=function(e){c.postMessage(e+"","*")},c.addEventListener("message",w,!1)):r="onreadystatechange"in f("script")?function(e){s.appendChild(f("script")).onreadystatechange=function(){s.removeChild(this),b.call(e)}}:function(e){setTimeout(o(b,e,1),0)}),e.exports={set:l,clear:h}},function(e,t,n){"use strict";var r=Math.ceil,i=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?i:r)(e)}},function(e,t,n){"use strict";var r=n(24),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){"use strict";e.exports={}},function(e,t,n){"use strict";var r={}.hasOwnProperty;e.exports=function(e,t){return r.call(e,t)}},function(e,t,n){"use strict";var r=n(2),i=n(31),a=n(27),o=n(33)("src"),u=Function.toString,s=(""+u).split("toString");n(7).inspectSource=function(e){return u.call(e)},(e.exports=function(e,t,n,u){var f="function"==typeof n;f&&(a(n,"name")||i(n,"name",t)),e[t]!==n&&(f&&(a(n,o)||i(n,o,e[t]?""+e[t]:s.join(String(t)))),e===r?e[t]=n:u?e[t]?e[t]=n:i(e,t,n):(delete e[t],i(e,t,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[o]||u.call(this)})},function(e,t,n){"use strict";var r=n(5),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t,n){"use strict";e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){"use strict";var r=n(14),i=n(119);e.exports=n(8)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){"use strict";var r=n(2),i=n(7),a=n(31),o=n(28),u=n(10),s=function e(t,n,s){var f,c,d,l,h=t&e.F,v=t&e.G,p=t&e.P,m=t&e.B,y=v?r:t&e.S?r[n]||(r[n]={}):(r[n]||{}).prototype,b=v?i:i[n]||(i[n]={}),w=b.prototype||(b.prototype={});for(f in v&&(s=n),s)d=((c=!h&&y&&void 0!==y[f])?y:s)[f],l=m&&c?u(d,r):p&&"function"==typeof d?u(Function.call,d):d,y&&o(y,f,d,t&e.U),b[f]!=d&&a(b,f,l),p&&w[f]!=d&&(w[f]=d)};r.core=i,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,e.exports=s},function(e,t,n){"use strict";var r=0,i=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++r+i).toString(36))}},function(e,t,n){"use strict";var r=n(15),i=n(3)("toStringTag"),a="Arguments"==r(function(){return arguments}());e.exports=function(e){var t,n,o;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),i))?n:a?r(t):"Object"==(o=r(t))&&"function"==typeof t.callee?"Arguments":o}},function(e,t,n){"use strict";e.exports=!1},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,i.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.updating=!1,this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",new a.default("mse","",{line:16,handle:"[MSE] constructor sourceopen",msg:e.message}))}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen")}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return r(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.state&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={findBox:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e.type!==t){if(e&&e.subBox){var i=e.subBox.filter(function(e){return e.type===t});i.length?i.forEach(function(e){return n.push(e)}):e.subBox.forEach(function(e){return r.findBox(e,t,n)})}}else n.push(e);return(n=[].concat(n)).length>1?n:n[0]},padStart:function(e,t,n){for(var r=String(n),i=t>>0,a=Math.ceil(i/r.length),o=[],u=String(e);a--;)o.push(r);return o.join("").substring(0,i-u.length)+u},toHex:function(){for(var e=[],t=arguments.length,n=Array(t),i=0;i>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new o.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new o.default,r=8,i=e.mvhd(t.duration,t.timeScale),a=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration,t.timeScale);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),i,a,u,s),n.buffer}},{key:"mvhd",value:function(t,n){var r=new o.default;t*=n;var i=Math.floor(t/(u+1)),a=Math.floor(t%(u+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return r.write(e.size(8+s.length),e.type("mvhd"),new Uint8Array(s)),r.buffer}},{key:"videoTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:1,duration:t.videoDuration,timescale:t.videoTimeScale,width:t.width,height:t.height,type:"video"}),a=e.mdia({type:"video",timescale:t.videoTimeScale,duration:t.videoDuration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"audioTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:2,duration:t.audioDuration,timescale:t.audioTimeScale,width:0,height:0,type:"audio"}),a=e.mdia({type:"audio",timescale:t.audioTimeScale,duration:t.audioDuration,channelCount:t.channelCount,samplerate:t.sampleRate,audioConfig:t.audioConfig});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"tkhd",value:function(t){var n=new o.default,r=t.id,i=t.duration*t.timeScale,a=t.width,s=t.height,f=t.type,c=Math.floor(i/(u+1)),d=Math.floor(i%(u+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new o.default,r=t.duration,i=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new o.default,r=8,i=e.mdhd(t.timescale),a=e.hdlr(t.type),u=e.minf(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),i,a,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new o.default;n*=t;var i=Math.floor(n/(u+1)),a=Math.floor(n%(u+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new o.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new o.default,r=8,i="video"===t.type?e.vmhd():e.smhd(),a=e.dinf(),u=e.stbl(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),i,a,u),n.buffer}},{key:"vmhd",value:function(){var t=new o.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new o.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new o.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new o.default,r=8,i=e.stsd(t),a=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[i,a,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),i,a,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new o.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),i=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+i.byteLength),e.type("mp4a"),r,i),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new o.default,i=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+i.byteLength),e.type("esds"),i),r.buffer}},{key:"avc1",value:function(t){var n=new o.default,r=t.sps,i=t.pps,a=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([i.length>>>8&255,255&i.length]).concat(i)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t,n){var r=new o.default,i=o.default.writeUint32(t*n);return r.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),i,e.trex(1),e.trex(2)),r.buffer}},{key:"trex",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new o.default,r=8,i=e.mfhd(),a=e.traf(t);return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),i,a),n.buffer}},{key:"mfhd",value:function(){var t=new o.default,n=o.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new o.default,r=8,i=e.tfhd(t.id),a=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),i,a,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new o.default,r=o.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new o.default,r=Math.floor(t/(u+1)),i=Math.floor(t%(u+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),o.default.writeUint32(r),o.default.writeUint32(i)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,i=1===r?16:12,a=new o.default,u=o.default.writeUint32(t.samples.length),s=o.default.writeUint32(96+i*t.samples.length+n);return a.write(e.size(20+i*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){a.write(o.default.writeUint32(e.duration)),a.write(o.default.writeUint32(e.size)),1===r?(a.write(o.default.writeUint32(e.key?33554432:16842752)),a.write(o.default.writeUint32(e.offset))):a.write(o.default.writeUint32(16777216))}),a.buffer}},{key:"sdtp",value:function(t){var n=new o.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new o.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();s.sequence=1,t.default=s,e.exports=t.default},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.avc1=function(){var e=new i.default(this.data);e.skip(6),this.dataReferenceIndex=e.readUint16(),e.skip(16),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.skip(4),this.frameCount=e.readUint16(),e.skip(1);for(var t=0;t<31;t++)String.fromCharCode(e.readUint8());for(this.depth=e.readUint16(),e.skip(2);e.position>16;var t=new r.default;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.MP4DecConfigDescrTag=function(e){var t=new r.default,n=void 0;return t.type=e.readUint8(),128===(n=e.readUint8())?(t.extend=!0,e.skip(2),n=e.readUint8()+5):n+=2,t.size=n,t.typeID=e.readUint8(),t.streamUint=e.readUint8(),t.bufferSize=i.default.readByte(e.dataview,3),t.maximum=e.readUint32(),t.average=e.readUint32(),t.subBox.push(r.default.MP4DecSpecificDescrTag(e)),t}},function(e,t,n){"use strict";var r,i=n(0),a=(r=i)&&r.__esModule?r:{default:r};a.default.MP4DecSpecificDescrTag=function(e){var t=new a.default,n=void 0,r=void 0;t.type=e.readUint8(),128===(n=e.readUint8())?(t.extend=!0,e.skip(2),r=(n=e.readUint8()+5)-5):(r=n,n+=2),t.size=n;for(var i=[],o=0;o1){var c=t[this.count-1],d=t[this.count-2];c.first_sample=d.first_sample+d.chunk_count*d.samples_per_chunk,c.chunk_count=0}delete this.subBox,delete this.data,e=null}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stsd=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.entryCount=e.readUint32();var t=new r.default;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stss=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.count=e.readUint32();var t=[];this.entries=t;for(var n=0,r=this.count;n>8,e.readUint16();for(var t=[],n=0;n<9;n++)t.push(e.readUint16()+"."+e.readUint16());this.matrix=t,this.width=e.readUint16()+"."+e.readUint16(),this.height=e.readUint16()+"."+e.readUint16(),delete this.data,delete this.subBox,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r,i=n(0);((r=i)&&r.__esModule?r:{default:r}).default.udta=function(){delete this.subBox}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default["url "]=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=[e.readUint8(),e.readUint8(),e.readUint8()];for(var t=[],n=e.buffer.byteLength;e.position1?n-1:0),i=1;i=8;){var u=new r.default;if(u.readHeader(o),u.size-8<=n-o.position)u.readBody(o),this.boxes.push(u);else{if("mdat"!==u.type){this.nextBox=u,o.position-=8;break}u.readBody(o),this.boxes.push(u)}}this.buffer=new Uint8Array(this.buffer.slice(o.position))},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e){return function(e){return!!e&&"object"===(void 0===e?"undefined":r(e))}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===a}(e)}(e)};var a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function u(e,t,n){return e.concat(t).map(function(e){return o(e,n)})}function s(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||u,n.isMergeableObject=n.isMergeableObject||i;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):function(e,t,n){var r={};return n.isMergeableObject(e)&&Object.keys(e).forEach(function(t){r[t]=o(e[t],n)}),Object.keys(t).forEach(function(i){n.isMergeableObject(t[i])&&e[i]?r[i]=s(e[i],t[i],n):r[i]=o(t[i],n)}),r}(e,t,n):o(t,n)}s.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})};var f=s;t.default=f,e.exports=t.default},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";var r=String.prototype.indexOf;e.exports=function(e){return r.call(this,e,arguments[1])>-1}},function(e,t,n){"use strict";var r="razdwatrzy";e.exports=function(){return"function"==typeof r.contains&&(!0===r.contains("dwa")&&!1===r.contains("foo"))}},function(e,t,n){"use strict";e.exports=n(87)()?String.prototype.contains:n(86)},function(e,t,n){"use strict";e.exports=function(e){return"function"==typeof e}},function(e,t,n){"use strict";var r=n(12),i=Array.prototype.forEach,a=Object.create;e.exports=function(e){var t=a(null);return i.call(arguments,function(e){r(e)&&function(e,t){var n;for(n in e)t[n]=e[n]}(Object(e),t)}),t}},function(e,t,n){"use strict";var r=n(12);e.exports=function(e){if(!r(e))throw new TypeError("Cannot use null or undefined");return e}},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";var r=n(12),i=Object.keys;e.exports=function(e){return i(r(e)?Object(e):e)}},function(e,t,n){"use strict";e.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},function(e,t,n){"use strict";e.exports=n(94)()?Object.keys:n(93)},function(e,t,n){"use strict";var r=n(95),i=n(91),a=Math.max;e.exports=function(e,t){var n,o,u,s=a(arguments.length,2);for(e=Object(i(e)),u=function(r){try{e[r]=t[r]}catch(e){n||(n=e)}},o=1;o1&&void 0!==arguments[1]?arguments[1]:Math.pow(25,4);!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(0,i.default)(this),this.url=t,this.CHUNK_SIZE=n,this.init(t),this.once("moovReady",this.moovParse.bind(this)),this.cache=new u.default,this.bufferCache=new Set,this.timeRage=[],this.canDownload=!0}return r(e,[{key:"getData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+this.CHUNK_SIZE,r=this;return new Promise(function(i,a){new f.default(e.url,[t,n],i).once("error",function(e){r.emit("error",e)})})}},{key:"moovParse",value:function(){var e=this,t=this,n=this.moovBox,r=c.default.findBox(n,"mvhd"),i=c.default.findBox(n,"trak"),o=void 0,u=void 0,s=void 0,f=void 0,l=void 0,h=void 0,v=void 0,p=void 0,m=void 0,y=void 0,b=void 0,w=void 0,g=void 0,_=void 0;i.forEach(function(e){var n=c.default.findBox(e,"hdlr"),r=c.default.findBox(e,"mdhd");if(n&&r){var i=c.default.findBox(e,"stsd").subBox[0];if("vide"===n.handleType){var a=c.default.findBox(e,"avcC"),x=c.default.findBox(e,"avc1");o=e,l=r.timescale,a?(s=i.type+"."+c.default.toHex(a.profile,a.profileCompatibility,a.AVCLevelIndication).join(""),v=a.sequence&&a.sequence.map(function(e){return Number("0x"+e)}),p=a.pps&&a.pps.map(function(e){return Number("0x"+e)}),m=a.profile):s=""+i.type,x&&(y=x.width,b=x.height)}if("soun"===n.handleType){u=e;var U=c.default.findBox(e,"esds"),k=c.default.findBox(e,"mp4a"),S=c.default.findBox(e,5);h=r.timescale,f=U?i.type+"."+c.default.toHex(U.subBox[0].subBox[0].typeID)+"."+U.subBox[0].subBox[0].subBox[0].type:""+i.type,S&&S.EScode&&(_=S.EScode.map(function(e){return Number("0x"+e)})),k&&(w=k.channelCount,g=k.sampleRate)}}else t.emit("error",new d.default("parse","",{line:72,handle:"[MP4] moovParse",url:t.url}))}),this.videoTrak=(0,a.default)({},o),this.audioTrak=(0,a.default)({},u);var x=this._boxes.find(function(e){return"mdat"===e.type}),U=c.default.seekTrakDuration(o,l),k=c.default.seekTrakDuration(u,h);this.mdatStart=x.start;var S=this.videoKeyFrames,B=S.length-1;S.forEach(function(t,n){n0&&void 0!==arguments[0]?arguments[0]:"video",t=arguments[1],n=arguments[2],r="video"===e?this.videoTrak:this.audioTrak,i=c.default.findBox(r,"stsc"),a=c.default.findBox(r,"stsz"),o=c.default.findBox(r,"stts"),u=c.default.findBox(r,"stco"),s=c.default.findBox(r,"ctts"),f=this.mdatStart,d=[];if(n=void 0!==n?n:a.entries.length,t instanceof Array)t.forEach(function(e,t){d.push({idx:e,size:a.entries[e],time:c.default.seekSampleTime(o,s,e),offset:c.default.seekSampleOffset(i,u,a,e,f)})});else if(0!==n)for(var l=t;l0;(a>>>=1)&&(t+=t))1&a&&(n+=t);return n}},function(e,t,n){"use strict";var r=n(25),i=n(101),a=n(20);e.exports=function(e,t,n,o){var u=String(a(e)),s=u.length,f=void 0===n?" ":String(n),c=r(t);if(c<=s||""==f)return u;var d=c-s,l=i.call(f,Math.ceil(d/f.length));return l.length>d&&(l=l.slice(0,d)),o?l+u:u+l}},function(e,t,n){"use strict";var r=n(32),i=n(102),a=n(21);r(r.P+r.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(a),"String",{padStart:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0,!0)}})},function(e,t,n){"use strict";var r=n(3)("iterator"),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch(e){}return n}},function(e,t,n){"use strict";var r=n(2),i=n(14),a=n(8),o=n(3)("species");e.exports=function(e){var t=r[e];a&&t&&!t[o]&&i.f(t,o,{configurable:!0,get:function(){return this}})}},function(e,t,n){"use strict";var r=n(14).f,i=n(27),a=n(3)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){"use strict";var r=n(28);e.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},function(e,t,n){"use strict";var r=n(6),i=n(5),a=n(22);e.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=a.f(e);return(0,n.resolve)(t),n.promise}},function(e,t,n){"use strict";e.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},function(e,t,n){"use strict";var r=n(2),i=n(23).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,u=r.Promise,s="process"==n(15)(o);e.exports=function(){var e,t,n,f=function(){var r,i;for(s&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(s)n=function(){o.nextTick(f)};else if(!a||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var c=u.resolve(void 0);n=function(){c.then(f)}}else n=function(){i.call(r,f)};else{var d=!0,l=document.createTextNode("");new a(f).observe(l,{characterData:!0}),n=function(){l.data=d=!d}}return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){"use strict";var r=n(2).document;e.exports=r&&r.documentElement},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){"use strict";var r=n(6),i=n(9),a=n(3)("species");e.exports=function(e,t){var n,o=r(e).constructor;return void 0===o||null==(n=r(o)[a])?t:i(n)}},function(e,t,n){"use strict";var r=n(34),i=n(3)("iterator"),a=n(26);e.exports=n(7).getIteratorMethod=function(e){if(null!=e)return e[i]||e["@@iterator"]||a[r(e)]}},function(e,t,n){"use strict";var r=n(26),i=n(3)("iterator"),a=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||a[i]===e)}},function(e,t,n){"use strict";var r=n(6);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw void 0!==a&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(10),i=n(116),a=n(115),o=n(6),u=n(25),s=n(114),f={},c={},d=e.exports=function(e,t,n,d,l){var h,v,p,m,y=l?function(){return e}:s(e),b=r(n,d,t?2:1),w=0;if("function"!=typeof y)throw TypeError(e+" is not iterable!");if(a(y)){for(h=u(e.length);h>w;w++)if((m=t?b(o(v=e[w])[0],v[1]):b(e[w]))===f||m===c)return m}else for(p=y.call(e);!(v=p.next()).done;)if((m=i(p,b,v.value,t))===f||m===c)return m};d.BREAK=f,d.RETURN=c},function(e,t,n){"use strict";e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t,n){"use strict";e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){"use strict";var r=n(5);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t,n){"use strict";e.exports=!n(8)&&!n(30)(function(){return 7!=Object.defineProperty(n(29)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";var r=n(7),i=n(2),a=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(e.exports=function(e,t){return a[e]||(a[e]=void 0!==t?t:{})})("versions",[]).push({version:r.version,mode:n(35)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(e,t,n){"use strict";var r,i,a,o,u=n(35),s=n(2),f=n(10),c=n(34),d=n(32),l=n(5),h=n(9),v=n(118),p=n(117),m=n(113),y=n(23).set,b=n(110)(),w=n(22),g=n(109),_=n(21),x=n(108),U=s.TypeError,k=s.process,S=k&&k.versions,B=S&&S.v8||"",M=s.Promise,T="process"==c(k),O=function(){},j=i=w.f,E=!!function(){try{var e=M.resolve(1),t=(e.constructor={})[n(3)("species")]=function(e){e(O,O)};return(T||"function"==typeof PromiseRejectionEvent)&&e.then(O)instanceof t&&0!==B.indexOf("6.6")&&-1===_.indexOf("Chrome/66")}catch(e){}}(),z=function(e){var t;return!(!l(e)||"function"!=typeof(t=e.then))&&t},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;b(function(){for(var r=e._v,i=1==e._s,a=0,o=function(t){var n,a,o,u=i?t.ok:t.fail,s=t.resolve,f=t.reject,c=t.domain;try{u?(i||(2==e._h&&D(e),e._h=1),!0===u?n=r:(c&&c.enter(),n=u(r),c&&(c.exit(),o=!0)),n===t.promise?f(U("Promise-chain cycle")):(a=z(n))?a.call(n,s,f):s(n)):f(r)}catch(e){c&&!o&&c.exit(),f(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&P(e)})}},P=function(e){y.call(s,function(){var t,n,r,i=e._v,a=A(e);if(a&&(t=g(function(){T?k.emit("unhandledRejection",i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error("Unhandled promise rejection",i)}),e._h=T||A(e)?2:1),e._a=void 0,a&&t.e)throw t.v})},A=function(e){return 1!==e._h&&0===(e._a||e._c).length},D=function(e){y.call(s,function(){var t;T?k.emit("rejectionHandled",e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},L=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),C(t,!0))},R=function e(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw U("Promise can't be resolved itself");(n=z(t))?b(function(){var i={_w:r,_d:!1};try{n.call(t,f(e,i,1),f(L,i,1))}catch(e){L.call(i,e)}}):(r._v=t,r._s=1,C(r,!1))}catch(e){L.call({_w:r,_d:!1},e)}}};E||(M=function(e){v(this,M,"Promise","_h"),h(e),r.call(this);try{e(f(R,this,1),f(L,this,1))}catch(e){L.call(this,e)}},(r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=n(107)(M.prototype,{then:function(e,t){var n=j(m(this,M));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=T?k.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),a=function(){var e=new r;this.promise=e,this.resolve=f(R,e,1),this.reject=f(L,e,1)},w.f=j=function(e){return e===M||e===o?new a(e):i(e)}),d(d.G+d.W+d.F*!E,{Promise:M}),n(106)(M,"Promise"),n(105)("Promise"),o=n(7).Promise,d(d.S+d.F*!E,"Promise",{reject:function(e){var t=j(this);return(0,t.reject)(e),t.promise}}),d(d.S+d.F*(u||!E),"Promise",{resolve:function(e){return x(u&&this===o?M:this,e)}}),d(d.S+d.F*!(E&&n(104)(function(e){M.all(e).catch(O)})),"Promise",{all:function(e){var t=this,n=j(t),r=n.resolve,i=n.reject,a=g(function(){var n=[],a=0,o=1;p(e,!1,function(e){var u=a++,s=!1;n.push(void 0),o++,t.resolve(e).then(function(e){s||(s=!0,n[u]=e,--o||r(n))},i)}),--o||r(n)});return a.e&&i(a.v),n.promise},race:function(e){var t=this,n=j(t),r=n.reject,i=g(function(){p(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}})},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n(123),n(103);var i=s(n(19)),a=s(n(100)),o=s(n(36)),u=s(n(16));function s(e){return e&&e.__esModule?e:{default:e}}var f=function(e,t){t.vid=e.config.vid,t.url=e.src,t.errd&&"object"===r(t.errd)&&e.mp4&&(t.errd.url=e.mp4.url,t.url=e.mp4.url,e.mp4.canDownload=!1),e.emit("DATA_REPORT",t),"network"===t.errt&&e.config._backupURL?e.src=e.config._backupURL:e.src=e.config._mainURL,e.switchURL=null,e._replay=null};i.default.install("mp4player",function(){var e=this,t=i.default.sniffer,n=i.default.util,r=i.default.Errors,s=void 0,c=void 0,d=e.config.preloadTime||15,l=void 0,h=e.config.url,v=e.config.pluginRule||function(){return!0};if(h){"String"===n.typeOf(h)?s=h:"Array"===n.typeOf(h)&&h.length&&(s=h[0].src,c=h[1].src),e.config._mainURL=s,e.config._backupURL=c;var p=function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.currentTime;e.timer&&clearTimeout(e.timer),r=Math.max(r,e.currentTime),e.timer=setTimeout(function(){e.mp4.seek(r+.1*n).then(function(t){if(t){var n=e.mse;n.updating=!0,n.appendBuffer(t),n.once("updateend",function(){n.updating=!1})}},function(){n<10&&setTimeout(function(){t(n+1)},2e3)})},50)},m=function(t){var n=new a.default(t),r=void 0;return new Promise(function(t,i){n.once("moovReady",function(){(r=new o.default).on("sourceopen",function(){r.appendBuffer(n.packMeta()),r.once("updateend",p.bind(e))}),r.on("error",function(e){i(e)}),t([n,r])}),n.on("error",function(e){i(e)})})};if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&o.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var y=e.start;if(!v.call(e))return!1;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s;m(n).then(function(t){var n=t[0],r=t[1];y.call(e,r.url),e.mp4=n,e.mse=r,n.on("error",function(t){f(e,t)})},function(t){y.call(e,n),f(e,t)}),e.once("canplay",function(){if("safari"===t.browser&&e.buffered){var n=e.buffered.start(0);e.currentTime=n+.1}})},e.switchURL=function(n){var r=new a.default(n),i=e.mp4;r.on("moovReady",function(){i.timeRage;var n=e.currentTime,a=i.timeRage.find(function(e){return e[0]-n>2})[0],o=e.getBufferedRange()[1];o-a>0&&"safari"!==t.browser&&e.mse.removeBuffer(a,o),e.mp4=r,e.mse.appendBuffer(r.packMeta())}),r.on("error",function(t){f(e,t)})},e.on("timeupdate",function(){var t=e.mse,n=e.mp4;if(t&&!t.updating&&n.canDownload){var r=n.timeRage,i=e.getBufferedRange(),a=e.currentTime+d;if(i[1]-a>0)return;r.every(function(e,t){var r=(e[0]+e[1])/2;return 0===i[1]?(p(5),!1):!(r>i[1]&&!n.bufferCache.has(t))||void p(0,r)}),function(e,t){if(t.meta.endTime-e.currentTime<2){var n=e.getBufferedRange();e.currentTime-n[1]<.1&&e.mse.endOfStream()}}(e,n)}}),e.on("seeking",function(){var t=e.buffered,n=!1,r=e.currentTime;if(u.default.clear(),t.length){for(var i=0,a=t.length;i=t.start(i)&&r<=t.end(i)){n=!0;break}n||p(0,r)}else p(0,e.currentTime)}),e.on("pause",function(){u.default.clear()}),e.on("playing",function(){l&&clearTimeout(l)}),e.on("waiting",function(){var t=e.mp4;if(t&&t.meta){var n=e.getBufferedRange(),r=t.meta.videoDuration;r-e.currentTime<.5&&r-n[1]<.5?e.mse.endOfStream():(p(0,n[1]+1),l=setTimeout(function(){for(var t=e.buffered,n=void 0,r=0,i=t.length;r=e.currentTime){e.currentTime=n;break}},1500))}}),e.once("destroy",function(){u.default.clear(),e.timer&&clearTimeout(e.timer)}),e._replay=function(){u.default.clear(),e.mp4.bufferCache.clear(),m(e.mp4.url).then(function(t){var n=t[0],r=t[1];e.src=r.url,e.mp4=n,e.mse=r,e.currentTime=0,e.play()},function(t){f(e,t)})}}}else e.emit("error",new r("other",e.config.vid))})},function(e,t,n){e.exports=n(124)}]); \ No newline at end of file diff --git a/packages/xgplayer-mp4/dist/index.js b/packages/xgplayer-mp4/dist/index.js index 0924f5ef9..b1ae7743f 100644 --- a/packages/xgplayer-mp4/dist/index.js +++ b/packages/xgplayer-mp4/dist/index.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("xgplayer")):"function"==typeof define&&define.amd?define(["xgplayer"],t):"object"==typeof exports?exports["xgplayer-mp4"]=t(require("xgplayer")):e["xgplayer-mp4"]=t(e.xgplayer)}(window,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=36)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw new i.default("parse","",{line:73,handle:"[Stream] readByte",msg:"not supported for readBody 8"});r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t,n){"use strict";var r=n(39)("wks"),i=n(18),a=n(2).Symbol,o="function"==typeof a;(e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)("Symbol."+e))}).store=r},function(e,t,n){"use strict";var r=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(e,t,n){"use strict";var r=n(6);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function(e){return"object"===(void 0===e?"undefined":r(e))?null!==e:"function"==typeof e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(e){return e&&e.__esModule?e:{default:e}}(n(32)),i=n(79);var a=function(e){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r.version=i.version;var o=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));return o.url=a,o}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,r.default.Errors),t}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";var r=n(9);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){"use strict";e.exports=!n(21)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";var r={}.toString;e.exports=function(e){return r.call(e).slice(8,-1)}},function(e,t,n){"use strict";var r=n(5),i=n(40),a=n(41),o=Object.defineProperty;t.f=n(10)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){"use strict";var r,i,a,o,u,s,f,c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=n(62),l=n(76),h=Function.prototype.apply,p=Function.prototype.call,v=Object.create,m=Object.defineProperty,y=Object.defineProperties,b=Object.prototype.hasOwnProperty,w={configurable:!0,enumerable:!1,writable:!0};u={on:r=function(e,t){var n;return l(t),b.call(this,"__ee__")?n=this.__ee__:(n=w.value=v(null),m(this,"__ee__",w),w.value=null),n[e]?"object"===c(n[e])?n[e].push(t):n[e]=[n[e],t]:n[e]=t,this},once:i=function(e,t){var n,i;return l(t),i=this,r.call(this,e,n=function(){a.call(i,e,n),h.call(t,this,arguments)}),n.__eeOnceListener__=t,this},off:a=function(e,t){var n,r,i,a;if(l(t),!b.call(this,"__ee__"))return this;if(!(n=this.__ee__)[e])return this;if("object"===(void 0===(r=n[e])?"undefined":c(r)))for(a=0;i=r[a];++a)i!==t&&i.__eeOnceListener__!==t||(2===r.length?n[e]=r[a?0:1]:r.splice(a,1));else r!==t&&r.__eeOnceListener__!==t||delete n[e];return this},emit:o=function(e){var t,n,r,i,a;if(b.call(this,"__ee__")&&(i=this.__ee__[e]))if("object"===(void 0===i?"undefined":c(i))){for(n=arguments.length,a=new Array(n-1),t=1;t0?i(r(e),9007199254740991):0}},function(e,t,n){"use strict";var r=Math.ceil,i=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?i:r)(e)}},function(e,t,n){"use strict";var r,i,a,o=n(8),u=n(49),s=n(50),f=n(22),c=n(2),d=c.process,l=c.setImmediate,h=c.clearImmediate,p=c.MessageChannel,v=c.Dispatch,m=0,y={},b=function(){var e=+this;if(y.hasOwnProperty(e)){var t=y[e];delete y[e],t()}},w=function(e){b.call(e.data)};l&&h||(l=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return y[++m]=function(){u("function"==typeof e?e:Function(e),t)},r(m),m},h=function(e){delete y[e]},"process"==n(11)(d)?r=function(e){d.nextTick(o(b,e,1))}:v&&v.now?r=function(e){v.now(o(b,e,1))}:p?(a=(i=new p).port2,i.port1.onmessage=w,r=o(a.postMessage,a,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScripts?(r=function(e){c.postMessage(e+"","*")},c.addEventListener("message",w,!1)):r="onreadystatechange"in f("script")?function(e){s.appendChild(f("script")).onreadystatechange=function(){s.removeChild(this),b.call(e)}}:function(e){setTimeout(o(b,e,1),0)}),e.exports={set:l,clear:h}},function(e,t,n){"use strict";var r=n(9);e.exports.f=function(e){return new function(e){var t,n;this.promise=new e(function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r}),this.resolve=r(t),this.reject=r(n)}(e)}},function(e,t,n){"use strict";var r=n(2).navigator;e.exports=r&&r.userAgent||""},function(e,t,n){"use strict";e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(t,n){t.exports=e},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(80));e.exports=r.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.currentTime;e.timer&&clearTimeout(e.timer),r=Math.max(r,e.currentTime),e.timer=setTimeout(function(){e.mp4.seek(r+.1*n).then(function(t){if(t){var n=e.mse;n.updating=!0,n.appendBuffer(t),n.once("updateend",function(){n.updating=!1})}},function(){n<10&&setTimeout(function(){t(n+1)},2e3)})},50)},m=function(t){var n=new a.default(t),r=void 0;return new Promise(function(t,i){n.once("moovReady",function(){(r=new o.default).on("sourceopen",function(){r.appendBuffer(n.packMeta()),r.once("updateend",v.bind(e))}),r.on("error",function(e){i(e)}),t([n,r])}),n.on("error",function(e){i(e)})})};if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&o.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var y=e.start;if(!p.call(e))return!1;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s;m(n).then(function(t){var n=t[0],r=t[1];y.call(e,r.url),e.mp4=n,e.mse=r,n.on("error",function(t){f(e,t)})},function(t){y.call(e,n),f(e,t)}),e.once("canplay",function(){if("safari"===t.browser&&e.buffered){var n=e.buffered.start(0);e.currentTime=n+.1}})},e.switchURL=function(n){var r=new a.default(n),i=e.mp4;r.on("moovReady",function(){i.timeRage;var n=e.currentTime,a=i.timeRage.find(function(e){return e[0]-n>2})[0],o=e.getBufferedRange()[1];o-a>0&&"safari"!==t.browser&&e.mse.removeBuffer(a,o),e.mp4=r,e.mse.appendBuffer(r.packMeta())}),r.on("error",function(t){f(e,t)})},e.on("timeupdate",function(){var t=e.mse,n=e.mp4;if(t&&!t.updating&&n.canDownload){var r=n.timeRage,i=e.getBufferedRange(),a=e.currentTime+d;if(i[1]-a>0)return;r.every(function(e,t){var r=(e[0]+e[1])/2;return 0===i[1]?(v(5),!1):!(r>i[1]&&!n.bufferCache.has(t))||void v(0,r)}),function(e,t){if(t.meta.endTime-e.currentTime<2){var n=e.getBufferedRange();e.currentTime-n[1]<.1&&e.mse.endOfStream()}}(e,n)}}),e.on("seeking",function(){var t=e.buffered,n=!1,r=e.currentTime;if(u.default.clear(),t.length){for(var i=0,a=t.length;i=t.start(i)&&r<=t.end(i)){n=!0;break}n||v(0,r)}else v(0,e.currentTime)}),e.on("pause",function(){u.default.clear()}),e.on("playing",function(){l&&clearTimeout(l)}),e.on("waiting",function(){var t=e.mp4;if(t&&t.meta){var n=e.getBufferedRange(),r=t.meta.videoDuration;r-e.currentTime<.5&&r-n[1]<.5?e.mse.endOfStream():(v(0,n[1]+1),l=setTimeout(function(){for(var t=e.buffered,n=void 0,r=0,i=t.length;r=e.currentTime){e.currentTime=n;break}},1500))}}),e._replay=function(){u.default.clear(),e.mp4.bufferCache.clear(),m(e.mp4.url).then(function(t){var n=t[0],r=t[1];e.src=r.url,e.mp4=n,e.mse=r,e.currentTime=0,e.play()},function(t){f(e,t)})}}}else e.emit("error",new r("other",e.config.vid))})},function(e,t,n){"use strict";var r,i,a,o,u=n(16),s=n(2),f=n(8),c=n(17),d=n(19),l=n(6),h=n(9),p=n(43),v=n(44),m=n(48),y=n(28).set,b=n(51)(),w=n(29),g=n(52),_=n(30),x=n(53),U=s.TypeError,k=s.process,S=k&&k.versions,B=S&&S.v8||"",M=s.Promise,T="process"==c(k),O=function(){},j=i=w.f,E=!!function(){try{var e=M.resolve(1),t=(e.constructor={})[n(3)("species")]=function(e){e(O,O)};return(T||"function"==typeof PromiseRejectionEvent)&&e.then(O)instanceof t&&0!==B.indexOf("6.6")&&-1===_.indexOf("Chrome/66")}catch(e){}}(),z=function(e){var t;return!(!l(e)||"function"!=typeof(t=e.then))&&t},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;b(function(){for(var r=e._v,i=1==e._s,a=0,o=function(t){var n,a,o,u=i?t.ok:t.fail,s=t.resolve,f=t.reject,c=t.domain;try{u?(i||(2==e._h&&D(e),e._h=1),!0===u?n=r:(c&&c.enter(),n=u(r),c&&(c.exit(),o=!0)),n===t.promise?f(U("Promise-chain cycle")):(a=z(n))?a.call(n,s,f):s(n)):f(r)}catch(e){c&&!o&&c.exit(),f(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&P(e)})}},P=function(e){y.call(s,function(){var t,n,r,i=e._v,a=A(e);if(a&&(t=g(function(){T?k.emit("unhandledRejection",i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error("Unhandled promise rejection",i)}),e._h=T||A(e)?2:1),e._a=void 0,a&&t.e)throw t.v})},A=function(e){return 1!==e._h&&0===(e._a||e._c).length},D=function(e){y.call(s,function(){var t;T?k.emit("rejectionHandled",e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},L=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),C(t,!0))},R=function e(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw U("Promise can't be resolved itself");(n=z(t))?b(function(){var i={_w:r,_d:!1};try{n.call(t,f(e,i,1),f(L,i,1))}catch(e){L.call(i,e)}}):(r._v=t,r._s=1,C(r,!1))}catch(e){L.call({_w:r,_d:!1},e)}}};E||(M=function(e){p(this,M,"Promise","_h"),h(e),r.call(this);try{e(f(R,this,1),f(L,this,1))}catch(e){L.call(this,e)}},(r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=n(54)(M.prototype,{then:function(e,t){var n=j(m(this,M));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=T?k.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),a=function(){var e=new r;this.promise=e,this.resolve=f(R,e,1),this.reject=f(L,e,1)},w.f=j=function(e){return e===M||e===o?new a(e):i(e)}),d(d.G+d.W+d.F*!E,{Promise:M}),n(55)(M,"Promise"),n(56)("Promise"),o=n(4).Promise,d(d.S+d.F*!E,"Promise",{reject:function(e){var t=j(this);return(0,t.reject)(e),t.promise}}),d(d.S+d.F*(u||!E),"Promise",{resolve:function(e){return x(u&&this===o?M:this,e)}}),d(d.S+d.F*!(E&&n(57)(function(e){M.all(e).catch(O)})),"Promise",{all:function(e){var t=this,n=j(t),r=n.resolve,i=n.reject,a=g(function(){var n=[],a=0,o=1;v(e,!1,function(e){var u=a++,s=!1;n.push(void 0),o++,t.resolve(e).then(function(e){s||(s=!0,n[u]=e,--o||r(n))},i)}),--o||r(n)});return a.e&&i(a.v),n.promise},race:function(e){var t=this,n=j(t),r=n.reject,i=g(function(){v(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}})},function(e,t,n){"use strict";var r=n(4),i=n(2),a=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(e.exports=function(e,t){return a[e]||(a[e]=void 0!==t?t:{})})("versions",[]).push({version:r.version,mode:n(16)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(e,t,n){"use strict";e.exports=!n(10)&&!n(21)(function(){return 7!=Object.defineProperty(n(22)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";var r=n(6);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t,n){"use strict";e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){"use strict";e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t,n){"use strict";var r=n(8),i=n(45),a=n(46),o=n(5),u=n(26),s=n(47),f={},c={},d=e.exports=function(e,t,n,d,l){var h,p,v,m,y=l?function(){return e}:s(e),b=r(n,d,t?2:1),w=0;if("function"!=typeof y)throw TypeError(e+" is not iterable!");if(a(y)){for(h=u(e.length);h>w;w++)if((m=t?b(o(p=e[w])[0],p[1]):b(e[w]))===f||m===c)return m}else for(v=y.call(e);!(p=v.next()).done;)if((m=i(v,b,p.value,t))===f||m===c)return m};d.BREAK=f,d.RETURN=c},function(e,t,n){"use strict";var r=n(5);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw void 0!==a&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(25),i=n(3)("iterator"),a=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||a[i]===e)}},function(e,t,n){"use strict";var r=n(17),i=n(3)("iterator"),a=n(25);e.exports=n(4).getIteratorMethod=function(e){if(void 0!=e)return e[i]||e["@@iterator"]||a[r(e)]}},function(e,t,n){"use strict";var r=n(5),i=n(9),a=n(3)("species");e.exports=function(e,t){var n,o=r(e).constructor;return void 0===o||void 0==(n=r(o)[a])?t:i(n)}},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){"use strict";var r=n(2).document;e.exports=r&&r.documentElement},function(e,t,n){"use strict";var r=n(2),i=n(28).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,u=r.Promise,s="process"==n(11)(o);e.exports=function(){var e,t,n,f=function(){var r,i;for(s&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(s)n=function(){o.nextTick(f)};else if(!a||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var c=u.resolve(void 0);n=function(){c.then(f)}}else n=function(){i.call(r,f)};else{var d=!0,l=document.createTextNode("");new a(f).observe(l,{characterData:!0}),n=function(){l.data=d=!d}}return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){"use strict";e.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},function(e,t,n){"use strict";var r=n(5),i=n(6),a=n(29);e.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=a.f(e);return(0,n.resolve)(t),n.promise}},function(e,t,n){"use strict";var r=n(23);e.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},function(e,t,n){"use strict";var r=n(12).f,i=n(24),a=n(3)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){"use strict";var r=n(2),i=n(12),a=n(10),o=n(3)("species");e.exports=function(e){var t=r[e];a&&t&&!t[o]&&i.f(t,o,{configurable:!0,get:function(){return this}})}},function(e,t,n){"use strict";var r=n(3)("iterator"),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch(e){}return n}},function(e,t,n){"use strict";var r=n(19),i=n(59),a=n(30);r(r.P+r.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(a),"String",{padStart:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0,!0)}})},function(e,t,n){"use strict";var r=n(26),i=n(60),a=n(31);e.exports=function(e,t,n,o){var u=String(a(e)),s=u.length,f=void 0===n?" ":String(n),c=r(t);if(c<=s||""==f)return u;var d=c-s,l=i.call(f,Math.ceil(d/f.length));return l.length>d&&(l=l.slice(0,d)),o?l+u:u+l}},function(e,t,n){"use strict";var r=n(27),i=n(31);e.exports=function(e){var t=String(i(this)),n="",a=r(e);if(a<0||a==1/0)throw RangeError("Count can't be negative");for(;a>0;(a>>>=1)&&(t+=t))1&a&&(n+=t);return n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:Math.pow(25,4);!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(0,i.default)(this),this.url=t,this.CHUNK_SIZE=n,this.init(t),this.once("moovReady",this.moovParse.bind(this)),this.cache=new u.default,this.bufferCache=new Set,this.timeRage=[],this.canDownload=!0}return r(e,[{key:"getData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+this.CHUNK_SIZE,r=this;return new Promise(function(i,a){new f.default(e.url,[t,n],i).once("error",function(e){r.emit("error",e)})})}},{key:"moovParse",value:function(){var e=this,t=this,n=this.moovBox,r=c.default.findBox(n,"mvhd"),i=void 0,o=void 0,u=void 0,s=void 0,f=void 0,l=void 0,h=void 0,p=void 0,v=void 0,m=void 0,y=void 0,b=void 0,w=void 0,g=void 0;c.default.findBox(n,"trak").forEach(function(e){var n=c.default.findBox(e,"hdlr"),r=c.default.findBox(e,"mdhd");if(n&&r){var a=c.default.findBox(e,"stsd").subBox[0];if("vide"===n.handleType){var _=c.default.findBox(e,"avcC"),x=c.default.findBox(e,"avc1");i=e,f=r.timescale,_?(u=a.type+"."+c.default.toHex(_.profile,_.profileCompatibility,_.AVCLevelIndication).join(""),h=_.sequence&&_.sequence.map(function(e){return Number("0x"+e)}),p=_.pps&&_.pps.map(function(e){return Number("0x"+e)}),v=_.profile):u=""+a.type,x&&(m=x.width,y=x.height)}if("soun"===n.handleType){o=e;var U=c.default.findBox(e,"esds"),k=c.default.findBox(e,"mp4a"),S=c.default.findBox(e,5);l=r.timescale,s=U?a.type+"."+c.default.toHex(U.subBox[0].subBox[0].typeID)+"."+U.subBox[0].subBox[0].subBox[0].type:""+a.type,S&&S.EScode&&(g=S.EScode.map(function(e){return Number("0x"+e)})),k&&(b=k.channelCount,w=k.sampleRate)}}else t.emit("error",new d.default("parse","",{line:72,handle:"[MP4] moovParse",url:t.url}))}),this.videoTrak=(0,a.default)({},i),this.audioTrak=(0,a.default)({},o);var _=this._boxes.find(function(e){return"mdat"===e.type}),x=c.default.seekTrakDuration(i,f),U=c.default.seekTrakDuration(o,l);this.mdatStart=_.start;var k=this.videoKeyFrames,S=k.length-1;k.forEach(function(t,n){n0&&void 0!==arguments[0]?arguments[0]:"video",t=arguments[1],n=arguments[2],r="video"===e?this.videoTrak:this.audioTrak,i=c.default.findBox(r,"stsc"),a=c.default.findBox(r,"stsz"),o=c.default.findBox(r,"stts"),u=c.default.findBox(r,"stco"),s=c.default.findBox(r,"ctts"),f=this.mdatStart,d=[];if(n=void 0!==n?n:a.entries.length,t instanceof Array)t.forEach(function(e,t){d.push({idx:e,size:a.entries[e],time:c.default.seekSampleTime(o,s,e),offset:c.default.seekSampleOffset(i,u,a,e,f)})});else if(0!==n)for(var l=t;l-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e){return function(e){return!!e&&"object"===(void 0===e?"undefined":r(e))}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===a}(e)}(e)};var a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(function(e){return Array.isArray(e)?[]:{}}(e),e,t):e}function u(e,t,n){return e.concat(t).map(function(e){return o(e,n)})}function s(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||u,n.isMergeableObject=n.isMergeableObject||i;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):function(e,t,n){var r={};return n.isMergeableObject(e)&&Object.keys(e).forEach(function(t){r[t]=o(e[t],n)}),Object.keys(t).forEach(function(i){n.isMergeableObject(t[i])&&e[i]?r[i]=s(e[i],t[i],n):r[i]=o(t[i],n)}),r}(e,t,n):o(t,n)}s.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})};var f=s;t.default=f,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=V(n(0)),i=V(n(33)),a=V(n(1)),o=V(n(81)),u=V(n(82)),s=V(n(83)),f=V(n(84)),c=V(n(85)),d=V(n(86)),l=V(n(87)),h=V(n(88)),p=V(n(89)),v=V(n(90)),m=V(n(91)),y=V(n(92)),b=V(n(93)),w=V(n(94)),g=V(n(95)),_=V(n(96)),x=V(n(97)),U=V(n(98)),k=V(n(99)),S=V(n(100)),B=V(n(101)),M=V(n(102)),T=V(n(103)),O=V(n(104)),j=V(n(105)),E=V(n(106)),z=V(n(107)),C=V(n(108)),P=V(n(109)),A=V(n(110)),D=V(n(111)),L=V(n(112)),R=V(n(113)),F=V(n(114)),I=V(n(115)),N=V(n(116)),q=V(n(117)),K=V(n(118)),H=V(n(119)),G=V(n(120));function V(e){return e&&e.__esModule?e:{default:e}}var W={};function X(e,t,n){var r=e;t.map(function(e,i){r[e]=i==t.length-1?n:r[e]||{},r=r[e]})}X(W,["box","avc1"],V(n(121)).default),X(W,["box","avcC"],G.default),X(W,["box","btrt"],H.default),X(W,["box","co64"],K.default),X(W,["box","ctts"],q.default),X(W,["box","dref"],N.default),X(W,["box","elst"],I.default),X(W,["box","esds"],F.default),X(W,["box","ftyp"],R.default),X(W,["box","hdlr"],L.default),X(W,["box","hmhd"],D.default),X(W,["box","iods"],A.default),X(W,["box","mdat"],P.default),X(W,["box","mdhd"],C.default),X(W,["box","mfhd"],z.default),X(W,["box","mp4a"],E.default),X(W,["box","MP4DecConfigDescrTag"],j.default),X(W,["box","MP4DecSpecificDescrTag"],O.default),X(W,["box","MP4ESDescrTag"],T.default),X(W,["box","mvhd"],M.default),X(W,["box","nmhd"],B.default),X(W,["box","pasp"],S.default),X(W,["box","sbgp"],k.default),X(W,["box","sdtp"],U.default),X(W,["box","SLConfigDescriptor"],x.default),X(W,["box","smhd"],_.default),X(W,["box","stco"],g.default),X(W,["box","stsc"],w.default),X(W,["box","stsd"],b.default),X(W,["box","stsh"],y.default),X(W,["box","stss"],m.default),X(W,["box","stsz"],v.default),X(W,["box","stts"],p.default),X(W,["box","stz2"],h.default),X(W,["box","tfhd"],l.default),X(W,["box","tkhd"],d.default),X(W,["box","traf"],c.default),X(W,["box","trun"],f.default),X(W,["box","udta"],s.default),X(W,["box","url"],u.default),X(W,["box","vmhd"],o.default);t.default=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.buffer=null,this.boxes=[],this.nextBox=null,this.start=0;this.buffer?(0,i.default)(Uint8Array,this.buffer,t):this.buffer=t;var n=t.byteLength;t.position=0;for(var o=new a.default(t);n-o.position>=8;){var u=new r.default;if(u.readHeader(o),u.size-8<=n-o.position)u.readBody(o),this.boxes.push(u);else{if("mdat"!==u.type){this.nextBox=u,o.position-=8;break}u.readBody(o),this.boxes.push(u)}}this.buffer=new Uint8Array(this.buffer.slice(o.position))},e.exports=t.default},function(e){e.exports={name:"xgplayer-mp4",version:"1.0.5",description:"xgplayer plugin for mp4 transform to fmp4",main:"./dist/index.js",scripts:{prepare:"npm run build",build:"webpack --progress --display-chunks -p",watch:"webpack --progress --display-chunks -p --watch"},repository:{type:"git",url:"git@github.com:bytedance/xgplayer.git"},babel:{presets:["es2015"],plugins:["add-module-exports","babel-plugin-bulk-import"]},keywords:["mp4","fmp4","player","video"],author:"yinguohui@bytedance.com",license:"MIT",dependencies:{"babel-loader":"^7.1.4","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-bulk-import":"^1.0.2","babel-preset-es2015":"^6.24.1","concat-typed-array":"^1.0.2",deepmerge:"^2.0.1","event-emitter":"^0.3.5","json-loader":"^0.5.7",webpack:"^4.11.0"},peerDependency:{xgplayer:"^0.1.0"},devDependencies:{"babel-core":"^6.26.3"}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){for(var t=0,n=arguments.length,r=Array(n>1?n-1:0),i=1;i>8,e.readUint16();for(var t=[],n=0;n<9;n++)t.push(e.readUint16()+"."+e.readUint16());this.matrix=t,this.width=e.readUint16()+"."+e.readUint16(),this.height=e.readUint16()+"."+e.readUint16(),delete this.data,delete this.subBox,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stts=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.count=e.readUint32();for(var t=[],n=0,r=this.count;n1){var c=t[this.count-1],d=t[this.count-2];c.first_sample=d.first_sample+d.chunk_count*d.samples_per_chunk,c.chunk_count=0}delete this.subBox,delete this.data,e=null}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stco=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.count=e.readUint32();var t=[];this.entries=t;for(var n=0,r=this.count;n>16;var t=new r.default;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=o(n(0)),i=o(n(1)),a=o(n(15));function o(e){return e&&e.__esModule?e:{default:e}}r.default.mdhd=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),1===this.version?(this.create=e.readUint64(),this.modify=e.readUint64(),this.createTime=(new a.default).setTime(1e3*this.create),this.modifyTime=(new a.default).setTime(1e3*this.modify),this.timescale=e.readUint32(),this.duration=e.readUint64()):(this.create=e.readUint32(),this.modify=e.readUint32(),this.createTime=(new a.default).setTime(1e3*this.create),this.modifyTime=(new a.default).setTime(1e3*this.modify),this.timescale=e.readUint32(),this.duration=e.readUint32()),this.language=e.readUint16(),e.readUint16(),delete this.subBox,delete this.data,e=null}},function(e,t,n){"use strict";(function(e){return e&&e.__esModule?e:{default:e}})(n(0)).default.mdat=function(){delete this.subBox}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.iods=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3);for(var t=[],n=e.buffer.byteLength;e.position>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new i.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new i.default,r=8,a=e.mvhd(t.duration,t.timeScale),o=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration,t.timeScale);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),a,o,u,s),n.buffer}},{key:"mvhd",value:function(t,n){var r=new i.default;t*=n;var o=Math.floor(t/(a+1)),u=Math.floor(t%(a+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,o>>24,o>>16&255,o>>8&255,255&o,u>>24,u>>16&255,u>>8&255,255&u,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return r.write(e.size(8+s.length),e.type("mvhd"),new Uint8Array(s)),r.buffer}},{key:"videoTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:1,duration:t.videoDuration,timescale:t.videoTimeScale,width:t.width,height:t.height,type:"video"}),o=e.mdia({type:"video",timescale:t.videoTimeScale,duration:t.videoDuration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"audioTrak",value:function(t){var n=new i.default,r=8,a=e.tkhd({id:2,duration:t.audioDuration,timescale:t.audioTimeScale,width:0,height:0,type:"audio"}),o=e.mdia({type:"audio",timescale:t.audioTimeScale,duration:t.audioDuration,channelCount:t.channelCount,samplerate:t.sampleRate,audioConfig:t.audioConfig});return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),a,o),n.buffer}},{key:"tkhd",value:function(t){var n=new i.default,r=t.id,o=t.duration*t.timeScale,u=t.width,s=t.height,f=t.type,c=Math.floor(o/(a+1)),d=Math.floor(o%(a+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,u>>8&255,255&u,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new i.default,r=t.duration,a=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,a>>24&255,a>>16&255,a>>8&255,255&a,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new i.default,r=8,a=e.mdhd(t.timescale),o=e.hdlr(t.type),u=e.minf(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),a,o,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new i.default;n*=t;var o=Math.floor(n/(a+1)),u=Math.floor(n%(a+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,o>>24,o>>16&255,o>>8&255,255&o,u>>24,u>>16&255,u>>8&255,255&u,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new i.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new i.default,r=8,a="video"===t.type?e.vmhd():e.smhd(),o=e.dinf(),u=e.stbl(t);return[a,o,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),a,o,u),n.buffer}},{key:"vmhd",value:function(){var t=new i.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new i.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new i.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new i.default,r=8,a=e.stsd(t),o=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[a,o,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),a,o,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new i.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),a=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+a.byteLength),e.type("mp4a"),r,a),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new i.default,a=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+a.byteLength),e.type("esds"),a),r.buffer}},{key:"avc1",value:function(t){var n=new i.default,r=t.sps,a=t.pps,o=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([a.length>>>8&255,255&a.length]).concat(a)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new i.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t,n){var r=new i.default,a=i.default.writeUint32(t*n);return r.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),a,e.trex(1),e.trex(2)),r.buffer}},{key:"trex",value:function(t){var n=new i.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new i.default,r=8,a=e.mfhd(),o=e.traf(t);return[a,o].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),a,o),n.buffer}},{key:"mfhd",value:function(){var t=new i.default,n=i.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new i.default,r=8,a=e.tfhd(t.id),o=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[a,o,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),a,o,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new i.default,r=i.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new i.default,r=Math.floor(t/(a+1)),o=Math.floor(t%(a+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),i.default.writeUint32(r),i.default.writeUint32(o)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,a=1===r?16:12,o=new i.default,u=i.default.writeUint32(t.samples.length),s=i.default.writeUint32(96+a*t.samples.length+n);return o.write(e.size(20+a*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){o.write(i.default.writeUint32(e.duration)),o.write(i.default.writeUint32(e.size)),1===r?(o.write(i.default.writeUint32(e.key?33554432:16842752)),o.write(i.default.writeUint32(e.offset))):o.write(i.default.writeUint32(16777216))}),o.buffer}},{key:"sdtp",value:function(t){var n=new i.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new i.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();o.sequence=1,t.default=o,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=document.createElement("a"),i=new Blob([n]),a=document.createEvent("MouseEvents");a.initEvent("click",!1,!1),r.download=t,r.href=URL.createObjectURL(i),r.dispatchEvent(a)},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={findBox:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e.type!==t){if(e&&e.subBox){var i=e.subBox.filter(function(e){return e.type===t});i.length?i.forEach(function(e){return n.push(e)}):e.subBox.forEach(function(e){return r.findBox(e,t,n)})}}else n.push(e);return(n=[].concat(n)).length>1?n:n[0]},padStart:function(e,t,n){for(var r=String(n),i=t>>0,a=Math.ceil(i/r.length),o=[],u=String(e);a--;)o.push(r);return o.join("").substring(0,i-u.length)+u},toHex:function(){for(var e=[],t=arguments.length,n=Array(t),i=0;i0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,i.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.updating=!1,this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",new a.default("mse","",{line:16,handle:"[MSE] constructor sourceopen",msg:e.message}))}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen")}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return r(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.state&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=u,e.exports=t.default}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("xgplayer")):"function"==typeof define&&define.amd?define(["xgplayer"],t):"object"==typeof exports?exports["xgplayer-mp4"]=t(require("xgplayer")):e["xgplayer-mp4"]=t(e.xgplayer)}(window,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=125)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&e.readByte(this.dataview,r)}},{key:"readUint8",value:function(){return e.readByte(this.dataview,1)}},{key:"readUint16",value:function(){return e.readByte(this.dataview,2)}},{key:"readUint32",value:function(){return e.readByte(this.dataview,4)}},{key:"readUint64",value:function(){return e.readByte(this.dataview,8)}},{key:"readInt8",value:function(){return e.readByte(this.dataview,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this.dataview,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this.dataview,4,!0)}},{key:"position",set:function(e){this.dataview.position=e},get:function(){return this.dataview.position}}],[{key:"readByte",value:function(e,t,n){var r=void 0;switch(t){case 1:r=n?e.getInt8(e.position):e.getUint8(e.position);break;case 2:r=n?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(n)throw"not supported for readByte 3";r=e.getUint8(e.position)<<16,r|=e.getUint8(e.position+1)<<8,r|=e.getUint8(e.position+2);break;case 4:r=n?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(n)throw new o.default("parse","",{line:73,handle:"[Stream] readByte",msg:"not supported for readBody 8"});r=e.getUint32(e.position)<<32,r|=e.getUint32(e.position+4);break;default:r=""}return e.position+=t,r}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t,n){"use strict";var r=n(122)("wks"),i=n(33),a=n(2).Symbol,o="function"==typeof a;(e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)("Symbol."+e))}).store=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=n(19),a=(r=i)&&r.__esModule?r:{default:r},o=n(82);var u=function(e){function t(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r.version=o.version;var a=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r));return a.url=i,a}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,a.default.Errors),t}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=function(e){return"object"===(void 0===e?"undefined":r(e))?null!==e:"function"==typeof e}},function(e,t,n){"use strict";var r=n(5);e.exports=function(e){if(!r(e))throw TypeError(e+" is not an object!");return e}},function(e,t,n){"use strict";var r=e.exports={version:"2.5.7"};"number"==typeof __e&&(__e=r)},function(e,t,n){"use strict";e.exports=!n(30)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,n){"use strict";var r=n(9);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n>24,e>>16&255,e>>8&255,255&e])}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";var r,i=n(81),a=(r=i)&&r.__esModule?r:{default:r};e.exports=a.default},function(t,n){t.exports=e},function(e,t,n){"use strict";e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){"use strict";var r=n(2).navigator;e.exports=r&&r.userAgent||""},function(e,t,n){"use strict";var r=n(9);e.exports.f=function(e){return new function(e){var t,n;this.promise=new e(function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r}),this.resolve=r(t),this.reject=r(n)}(e)}},function(e,t,n){"use strict";var r,i,a,o=n(10),u=n(112),s=n(111),f=n(29),c=n(2),d=c.process,l=c.setImmediate,h=c.clearImmediate,p=c.MessageChannel,v=c.Dispatch,m=0,y={},b=function(){var e=+this;if(y.hasOwnProperty(e)){var t=y[e];delete y[e],t()}},w=function(e){b.call(e.data)};l&&h||(l=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return y[++m]=function(){u("function"==typeof e?e:Function(e),t)},r(m),m},h=function(e){delete y[e]},"process"==n(15)(d)?r=function(e){d.nextTick(o(b,e,1))}:v&&v.now?r=function(e){v.now(o(b,e,1))}:p?(a=(i=new p).port2,i.port1.onmessage=w,r=o(a.postMessage,a,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScripts?(r=function(e){c.postMessage(e+"","*")},c.addEventListener("message",w,!1)):r="onreadystatechange"in f("script")?function(e){s.appendChild(f("script")).onreadystatechange=function(){s.removeChild(this),b.call(e)}}:function(e){setTimeout(o(b,e,1),0)}),e.exports={set:l,clear:h}},function(e,t,n){"use strict";var r=Math.ceil,i=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?i:r)(e)}},function(e,t,n){"use strict";var r=n(24),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){"use strict";e.exports={}},function(e,t,n){"use strict";var r={}.hasOwnProperty;e.exports=function(e,t){return r.call(e,t)}},function(e,t,n){"use strict";var r=n(2),i=n(31),a=n(27),o=n(33)("src"),u=Function.toString,s=(""+u).split("toString");n(7).inspectSource=function(e){return u.call(e)},(e.exports=function(e,t,n,u){var f="function"==typeof n;f&&(a(n,"name")||i(n,"name",t)),e[t]!==n&&(f&&(a(n,o)||i(n,o,e[t]?""+e[t]:s.join(String(t)))),e===r?e[t]=n:u?e[t]?e[t]=n:i(e,t,n):(delete e[t],i(e,t,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[o]||u.call(this)})},function(e,t,n){"use strict";var r=n(5),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t,n){"use strict";e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){"use strict";var r=n(14),i=n(119);e.exports=n(8)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t,n){"use strict";var r=n(2),i=n(7),a=n(31),o=n(28),u=n(10),s=function e(t,n,s){var f,c,d,l,h=t&e.F,p=t&e.G,v=t&e.P,m=t&e.B,y=p?r:t&e.S?r[n]||(r[n]={}):(r[n]||{}).prototype,b=p?i:i[n]||(i[n]={}),w=b.prototype||(b.prototype={});for(f in p&&(s=n),s)d=((c=!h&&y&&void 0!==y[f])?y:s)[f],l=m&&c?u(d,r):v&&"function"==typeof d?u(Function.call,d):d,y&&o(y,f,d,t&e.U),b[f]!=d&&a(b,f,l),v&&w[f]!=d&&(w[f]=d)};r.core=i,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,e.exports=s},function(e,t,n){"use strict";var r=0,i=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++r+i).toString(36))}},function(e,t,n){"use strict";var r=n(15),i=n(3)("toStringTag"),a="Arguments"==r(function(){return arguments}());e.exports=function(e){var t,n,o;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),i))?n:a?r(t):"Object"==(o=r(t))&&"function"==typeof t.callee?"Arguments":o}},function(e,t,n){"use strict";e.exports=!1},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:'video/mp4; codecs="avc1.64001E, mp4a.40.5"';!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=this;(0,i.default)(this),this.codecs=t,this.mediaSource=new window.MediaSource,this.url=window.URL.createObjectURL(this.mediaSource),this.queue=[],this.updating=!1,this.mediaSource.addEventListener("sourceopen",function(){n.sourceBuffer=n.mediaSource.addSourceBuffer(n.codecs),n.sourceBuffer.addEventListener("error",function(e){n.emit("error",new a.default("mse","",{line:16,handle:"[MSE] constructor sourceopen",msg:e.message}))}),n.sourceBuffer.addEventListener("updateend",function(e){n.emit("updateend");var t=n.queue.shift();t&&n.sourceBuffer.appendBuffer(t)}),n.emit("sourceopen")}),this.mediaSource.addEventListener("sourceclose",function(){n.emit("sourceclose")})}return r(e,[{key:"appendBuffer",value:function(e){var t=this.sourceBuffer;return!1===t.updating&&"open"===this.state?(t.appendBuffer(e),!0):(this.queue.push(e),!1)}},{key:"removeBuffer",value:function(e,t){this.sourceBuffer.remove(e,t)}},{key:"endOfStream",value:function(){"open"===this.state&&this.mediaSource.endOfStream()}},{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={findBox:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];if(e.type!==t){if(e&&e.subBox){var i=e.subBox.filter(function(e){return e.type===t});i.length?i.forEach(function(e){return n.push(e)}):e.subBox.forEach(function(e){return r.findBox(e,t,n)})}}else n.push(e);return(n=[].concat(n)).length>1?n:n[0]},padStart:function(e,t,n){for(var r=String(n),i=t>>0,a=Math.ceil(i/r.length),o=[],u=String(e);a--;)o.push(r);return o.join("").substring(0,i-u.length)+u},toHex:function(){for(var e=[],t=arguments.length,n=Array(t),i=0;i>16&255,t>>8&255,255&t])}},{key:"ftyp",value:function(){var t=new o.default;return t.write(e.size(24),e.type("ftyp"),new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])),t.buffer}},{key:"moov",value:function(t){var n=new o.default,r=8,i=e.mvhd(t.duration,t.timeScale),a=e.videoTrak(t),u=e.audioTrak(t),s=e.mvex(t.duration,t.timeScale);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moov"),i,a,u,s),n.buffer}},{key:"mvhd",value:function(t,n){var r=new o.default;t*=n;var i=Math.floor(t/(u+1)),a=Math.floor(t%(u+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return r.write(e.size(8+s.length),e.type("mvhd"),new Uint8Array(s)),r.buffer}},{key:"videoTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:1,duration:t.videoDuration,timescale:t.videoTimeScale,width:t.width,height:t.height,type:"video"}),a=e.mdia({type:"video",timescale:t.videoTimeScale,duration:t.videoDuration,sps:t.sps,pps:t.pps,pixelRatio:t.pixelRatio,width:t.width,height:t.height});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"audioTrak",value:function(t){var n=new o.default,r=8,i=e.tkhd({id:2,duration:t.audioDuration,timescale:t.audioTimeScale,width:0,height:0,type:"audio"}),a=e.mdia({type:"audio",timescale:t.audioTimeScale,duration:t.audioDuration,channelCount:t.channelCount,samplerate:t.sampleRate,audioConfig:t.audioConfig});return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("trak"),i,a),n.buffer}},{key:"tkhd",value:function(t){var n=new o.default,r=t.id,i=t.duration*t.timeScale,a=t.width,s=t.height,f=t.type,c=Math.floor(i/(u+1)),d=Math.floor(i%(u+1)),l=new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d,0,0,0,0,0,0,0,0,0,0,0,"video"===f?1:0,"audio"===f?1:0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]);return n.write(e.size(8+l.byteLength),e.type("tkhd"),l),n.buffer}},{key:"edts",value:function(t){var n=new o.default,r=t.duration,i=t.mediaTime;return n.write(e.size(36),e.type("edts")),n.write(e.size(28),e.type("elst")),n.write(new Uint8Array([0,0,0,1,r>>24&255,r>>16&255,r>>8&255,255&r,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,1])),n.buffer}},{key:"mdia",value:function(t){var n=new o.default,r=8,i=e.mdhd(t.timescale),a=e.hdlr(t.type),u=e.minf(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("mdia"),i,a,u),n.buffer}},{key:"mdhd",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new o.default;n*=t;var i=Math.floor(n/(u+1)),a=Math.floor(n%(u+1)),s=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]);return r.write(e.size(12+s.byteLength),e.type("mdhd"),e.extension(1,0),s),r.buffer}},{key:"hdlr",value:function(t){var n=new o.default,r=[0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0];return"audio"===t&&(r.splice.apply(r,[8,4].concat([115,111,117,110])),r.splice.apply(r,[24,13].concat([83,111,117,110,100,72,97,110,100,108,101,114,0]))),n.write(e.size(8+r.length),e.type("hdlr"),new Uint8Array(r)),n.buffer}},{key:"minf",value:function(t){var n=new o.default,r=8,i="video"===t.type?e.vmhd():e.smhd(),a=e.dinf(),u=e.stbl(t);return[i,a,u].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("minf"),i,a,u),n.buffer}},{key:"vmhd",value:function(){var t=new o.default;return t.write(e.size(20),e.type("vmhd"),new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])),t.buffer}},{key:"smhd",value:function(){var t=new o.default;return t.write(e.size(16),e.type("smhd"),new Uint8Array([0,0,0,0,0,0,0,0])),t.buffer}},{key:"dinf",value:function(){var t=new o.default;return t.write(e.size(36),e.type("dinf"),e.size(28),e.type("dref"),new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),t.buffer}},{key:"stbl",value:function(t){var n=new o.default,r=8,i=e.stsd(t),a=e.stts(),u=e.stsc(),s=e.stsz(),f=e.stco();return[i,a,u,s,f].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("stbl"),i,a,u,s,f),n.buffer}},{key:"stsd",value:function(t){var n=new o.default,r=void 0;return r="audio"===t.type?e.mp4a(t):e.avc1(t),n.write(e.size(16+r.byteLength),e.type("stsd"),e.extension(0,0),new Uint8Array([0,0,0,1]),r),n.buffer}},{key:"mp4a",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,t.samplerate>>8&255,255&t.samplerate,0,0]),i=e.esds(t.audioConfig);return n.write(e.size(8+r.byteLength+i.byteLength),e.type("mp4a"),r,i),n.buffer}},{key:"esds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[43,146,8,0],n=t.length,r=new o.default,i=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(t).concat([6,1,2]));return r.write(e.size(8+i.byteLength),e.type("esds"),i),r.buffer}},{key:"avc1",value:function(t){var n=new o.default,r=t.sps,i=t.pps,a=t.width,u=t.height,s=t.pixelRatio[0],f=t.pixelRatio[1],c=new Uint8Array([1,r[1],r[2],r[3],255,225].concat([r.length>>>8&255,255&r.length]).concat(r).concat(1).concat([i.length>>>8&255,255&i.length]).concat(i)),d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),l=new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]),h=new Uint8Array([s>>24,s>>16&255,s>>8&255,255&s,f>>24,f>>16&255,f>>8&255,255&f]);return n.write(e.size(40+d.byteLength+c.byteLength+l.byteLength),e.type("avc1"),d,e.size(8+c.byteLength),e.type("avcC"),c,e.size(20),e.type("btrt"),l,e.size(16),e.type("pasp"),h),n.buffer}},{key:"stts",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stts"),n),t.buffer}},{key:"stsc",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stsc"),n),t.buffer}},{key:"stco",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0]);return t.write(e.size(16),e.type("stco"),n),t.buffer}},{key:"stsz",value:function(){var t=new o.default,n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]);return t.write(e.size(20),e.type("stsz"),n),t.buffer}},{key:"mvex",value:function(t,n){var r=new o.default,i=o.default.writeUint32(t*n);return r.write(e.size(88),e.type("mvex"),e.size(16),e.type("mehd"),e.extension(0,0),i,e.trex(1),e.trex(2)),r.buffer}},{key:"trex",value:function(t){var n=new o.default,r=new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return n.write(e.size(8+r.byteLength),e.type("trex"),r),n.buffer}},{key:"moof",value:function(t){var n=new o.default,r=8,i=e.mfhd(),a=e.traf(t);return[i,a].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("moof"),i,a),n.buffer}},{key:"mfhd",value:function(){var t=new o.default,n=o.default.writeUint32(e.sequence);return e.sequence+=1,t.write(e.size(16),e.type("mfhd"),e.extension(0,0),n),t.buffer}},{key:"traf",value:function(t){var n=new o.default,r=8,i=e.tfhd(t.id),a=e.tfdt(t.time),u=e.sdtp(t),s=e.trun(t,u.byteLength);return[i,a,u,s].forEach(function(e){r+=e.byteLength}),n.write(e.size(r),e.type("traf"),i,a,u,s),n.buffer}},{key:"tfhd",value:function(t){var n=new o.default,r=o.default.writeUint32(t);return n.write(e.size(16),e.type("tfhd"),e.extension(0,0),r),n.buffer}},{key:"tfdt",value:function(t){var n=new o.default,r=Math.floor(t/(u+1)),i=Math.floor(t%(u+1));return n.write(e.size(20),e.type("tfdt"),e.extension(1,0),o.default.writeUint32(r),o.default.writeUint32(i)),n.buffer}},{key:"trun",value:function(t,n){var r=t.id,i=1===r?16:12,a=new o.default,u=o.default.writeUint32(t.samples.length),s=o.default.writeUint32(96+i*t.samples.length+n);return a.write(e.size(20+i*t.samples.length),e.type("trun"),e.extension(0,t.flags),u,s),t.samples.forEach(function(e,t){a.write(o.default.writeUint32(e.duration)),a.write(o.default.writeUint32(e.size)),1===r?(a.write(o.default.writeUint32(e.key?33554432:16842752)),a.write(o.default.writeUint32(e.offset))):a.write(o.default.writeUint32(16777216))}),a.buffer}},{key:"sdtp",value:function(t){var n=new o.default;return n.write(e.size(12+t.samples.length),e.type("sdtp"),e.extension(0,0)),t.samples.forEach(function(e){n.write(new Uint8Array(1===t.id?[e.key?32:16]:[16]))}),n.buffer}},{key:"mdat",value:function(t){var n=new o.default,r=8;return t.samples.forEach(function(e){r+=e.size}),n.write(e.size(r),e.type("mdat")),t.samples.forEach(function(e){n.write(e.buffer)}),n.buffer}}]),e}();s.sequence=1,t.default=s,e.exports=t.default},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.avc1=function(){var e=new i.default(this.data);e.skip(6),this.dataReferenceIndex=e.readUint16(),e.skip(16),this.width=e.readUint16(),this.height=e.readUint16(),this.horizresolution=e.readUint32(),this.vertresolution=e.readUint32(),e.skip(4),this.frameCount=e.readUint16(),e.skip(1);for(var t=0;t<31;t++)String.fromCharCode(e.readUint8());for(this.depth=e.readUint16(),e.skip(2);e.position>16;var t=new r.default;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.MP4DecConfigDescrTag=function(e){var t=new r.default,n=void 0;return t.type=e.readUint8(),128===(n=e.readUint8())?(t.extend=!0,e.skip(2),n=e.readUint8()+5):n+=2,t.size=n,t.typeID=e.readUint8(),t.streamUint=e.readUint8(),t.bufferSize=i.default.readByte(e.dataview,3),t.maximum=e.readUint32(),t.average=e.readUint32(),t.subBox.push(r.default.MP4DecSpecificDescrTag(e)),t}},function(e,t,n){"use strict";var r,i=n(0),a=(r=i)&&r.__esModule?r:{default:r};a.default.MP4DecSpecificDescrTag=function(e){var t=new a.default,n=void 0,r=void 0;t.type=e.readUint8(),128===(n=e.readUint8())?(t.extend=!0,e.skip(2),r=(n=e.readUint8()+5)-5):(r=n,n+=2),t.size=n;for(var i=[],o=0;o1){var c=t[this.count-1],d=t[this.count-2];c.first_sample=d.first_sample+d.chunk_count*d.samples_per_chunk,c.chunk_count=0}delete this.subBox,delete this.data,e=null}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stsd=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.entryCount=e.readUint32();var t=new r.default;t.readHeader(e),this.subBox.push(t),t.readBody(e),delete this.data,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default.stss=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=i.default.readByte(e.dataview,3),this.count=e.readUint32();var t=[];this.entries=t;for(var n=0,r=this.count;n>8,e.readUint16();for(var t=[],n=0;n<9;n++)t.push(e.readUint16()+"."+e.readUint16());this.matrix=t,this.width=e.readUint16()+"."+e.readUint16(),this.height=e.readUint16()+"."+e.readUint16(),delete this.data,delete this.subBox,e=null}},function(e,t,n){"use strict"},function(e,t,n){"use strict"},function(e,t,n){"use strict";var r,i=n(0);((r=i)&&r.__esModule?r:{default:r}).default.udta=function(){delete this.subBox}},function(e,t,n){"use strict";var r=a(n(0)),i=a(n(1));function a(e){return e&&e.__esModule?e:{default:e}}r.default["url "]=function(){var e=new i.default(this.data);this.version=e.readUint8(),this.flag=[e.readUint8(),e.readUint8(),e.readUint8()];for(var t=[],n=e.buffer.byteLength;e.position1?n-1:0),i=1;i=8;){var u=new r.default;if(u.readHeader(o),u.size-8<=n-o.position)u.readBody(o),this.boxes.push(u);else{if("mdat"!==u.type){this.nextBox=u,o.position-=8;break}u.readBody(o),this.boxes.push(u)}}this.buffer=new Uint8Array(this.buffer.slice(o.position))},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(e){return function(e){return!!e&&"object"===(void 0===e?"undefined":r(e))}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===a}(e)}(e)};var a="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function u(e,t,n){return e.concat(t).map(function(e){return o(e,n)})}function s(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||u,n.isMergeableObject=n.isMergeableObject||i;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):function(e,t,n){var r={};return n.isMergeableObject(e)&&Object.keys(e).forEach(function(t){r[t]=o(e[t],n)}),Object.keys(t).forEach(function(i){n.isMergeableObject(t[i])&&e[i]?r[i]=s(e[i],t[i],n):r[i]=o(t[i],n)}),r}(e,t,n):o(t,n)}s.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return s(e,n,t)},{})};var f=s;t.default=f,e.exports=t.default},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";var r=String.prototype.indexOf;e.exports=function(e){return r.call(this,e,arguments[1])>-1}},function(e,t,n){"use strict";var r="razdwatrzy";e.exports=function(){return"function"==typeof r.contains&&(!0===r.contains("dwa")&&!1===r.contains("foo"))}},function(e,t,n){"use strict";e.exports=n(87)()?String.prototype.contains:n(86)},function(e,t,n){"use strict";e.exports=function(e){return"function"==typeof e}},function(e,t,n){"use strict";var r=n(12),i=Array.prototype.forEach,a=Object.create;e.exports=function(e){var t=a(null);return i.call(arguments,function(e){r(e)&&function(e,t){var n;for(n in e)t[n]=e[n]}(Object(e),t)}),t}},function(e,t,n){"use strict";var r=n(12);e.exports=function(e){if(!r(e))throw new TypeError("Cannot use null or undefined");return e}},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";var r=n(12),i=Object.keys;e.exports=function(e){return i(r(e)?Object(e):e)}},function(e,t,n){"use strict";e.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},function(e,t,n){"use strict";e.exports=n(94)()?Object.keys:n(93)},function(e,t,n){"use strict";var r=n(95),i=n(91),a=Math.max;e.exports=function(e,t){var n,o,u,s=a(arguments.length,2);for(e=Object(i(e)),u=function(r){try{e[r]=t[r]}catch(e){n||(n=e)}},o=1;o1&&void 0!==arguments[1]?arguments[1]:Math.pow(25,4);!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(0,i.default)(this),this.url=t,this.CHUNK_SIZE=n,this.init(t),this.once("moovReady",this.moovParse.bind(this)),this.cache=new u.default,this.bufferCache=new Set,this.timeRage=[],this.canDownload=!0}return r(e,[{key:"getData",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t+this.CHUNK_SIZE,r=this;return new Promise(function(i,a){new f.default(e.url,[t,n],i).once("error",function(e){r.emit("error",e)})})}},{key:"moovParse",value:function(){var e=this,t=this,n=this.moovBox,r=c.default.findBox(n,"mvhd"),i=c.default.findBox(n,"trak"),o=void 0,u=void 0,s=void 0,f=void 0,l=void 0,h=void 0,p=void 0,v=void 0,m=void 0,y=void 0,b=void 0,w=void 0,g=void 0,_=void 0;i.forEach(function(e){var n=c.default.findBox(e,"hdlr"),r=c.default.findBox(e,"mdhd");if(n&&r){var i=c.default.findBox(e,"stsd").subBox[0];if("vide"===n.handleType){var a=c.default.findBox(e,"avcC"),x=c.default.findBox(e,"avc1");o=e,l=r.timescale,a?(s=i.type+"."+c.default.toHex(a.profile,a.profileCompatibility,a.AVCLevelIndication).join(""),p=a.sequence&&a.sequence.map(function(e){return Number("0x"+e)}),v=a.pps&&a.pps.map(function(e){return Number("0x"+e)}),m=a.profile):s=""+i.type,x&&(y=x.width,b=x.height)}if("soun"===n.handleType){u=e;var U=c.default.findBox(e,"esds"),k=c.default.findBox(e,"mp4a"),S=c.default.findBox(e,5);h=r.timescale,f=U?i.type+"."+c.default.toHex(U.subBox[0].subBox[0].typeID)+"."+U.subBox[0].subBox[0].subBox[0].type:""+i.type,S&&S.EScode&&(_=S.EScode.map(function(e){return Number("0x"+e)})),k&&(w=k.channelCount,g=k.sampleRate)}}else t.emit("error",new d.default("parse","",{line:72,handle:"[MP4] moovParse",url:t.url}))}),this.videoTrak=(0,a.default)({},o),this.audioTrak=(0,a.default)({},u);var x=this._boxes.find(function(e){return"mdat"===e.type}),U=c.default.seekTrakDuration(o,l),k=c.default.seekTrakDuration(u,h);this.mdatStart=x.start;var S=this.videoKeyFrames,B=S.length-1;S.forEach(function(t,n){n0&&void 0!==arguments[0]?arguments[0]:"video",t=arguments[1],n=arguments[2],r="video"===e?this.videoTrak:this.audioTrak,i=c.default.findBox(r,"stsc"),a=c.default.findBox(r,"stsz"),o=c.default.findBox(r,"stts"),u=c.default.findBox(r,"stco"),s=c.default.findBox(r,"ctts"),f=this.mdatStart,d=[];if(n=void 0!==n?n:a.entries.length,t instanceof Array)t.forEach(function(e,t){d.push({idx:e,size:a.entries[e],time:c.default.seekSampleTime(o,s,e),offset:c.default.seekSampleOffset(i,u,a,e,f)})});else if(0!==n)for(var l=t;l0;(a>>>=1)&&(t+=t))1&a&&(n+=t);return n}},function(e,t,n){"use strict";var r=n(25),i=n(101),a=n(20);e.exports=function(e,t,n,o){var u=String(a(e)),s=u.length,f=void 0===n?" ":String(n),c=r(t);if(c<=s||""==f)return u;var d=c-s,l=i.call(f,Math.ceil(d/f.length));return l.length>d&&(l=l.slice(0,d)),o?l+u:u+l}},function(e,t,n){"use strict";var r=n(32),i=n(102),a=n(21);r(r.P+r.F*/Version\/10\.\d+(\.\d+)? Safari\//.test(a),"String",{padStart:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0,!0)}})},function(e,t,n){"use strict";var r=n(3)("iterator"),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch(e){}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch(e){}return n}},function(e,t,n){"use strict";var r=n(2),i=n(14),a=n(8),o=n(3)("species");e.exports=function(e){var t=r[e];a&&t&&!t[o]&&i.f(t,o,{configurable:!0,get:function(){return this}})}},function(e,t,n){"use strict";var r=n(14).f,i=n(27),a=n(3)("toStringTag");e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){"use strict";var r=n(28);e.exports=function(e,t,n){for(var i in t)r(e,i,t[i],n);return e}},function(e,t,n){"use strict";var r=n(6),i=n(5),a=n(22);e.exports=function(e,t){if(r(e),i(t)&&t.constructor===e)return t;var n=a.f(e);return(0,n.resolve)(t),n.promise}},function(e,t,n){"use strict";e.exports=function(e){try{return{e:!1,v:e()}}catch(e){return{e:!0,v:e}}}},function(e,t,n){"use strict";var r=n(2),i=n(23).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,u=r.Promise,s="process"==n(15)(o);e.exports=function(){var e,t,n,f=function(){var r,i;for(s&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(s)n=function(){o.nextTick(f)};else if(!a||r.navigator&&r.navigator.standalone)if(u&&u.resolve){var c=u.resolve(void 0);n=function(){c.then(f)}}else n=function(){i.call(r,f)};else{var d=!0,l=document.createTextNode("");new a(f).observe(l,{characterData:!0}),n=function(){l.data=d=!d}}return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){"use strict";var r=n(2).document;e.exports=r&&r.documentElement},function(e,t,n){"use strict";e.exports=function(e,t,n){var r=void 0===n;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){"use strict";var r=n(6),i=n(9),a=n(3)("species");e.exports=function(e,t){var n,o=r(e).constructor;return void 0===o||null==(n=r(o)[a])?t:i(n)}},function(e,t,n){"use strict";var r=n(34),i=n(3)("iterator"),a=n(26);e.exports=n(7).getIteratorMethod=function(e){if(null!=e)return e[i]||e["@@iterator"]||a[r(e)]}},function(e,t,n){"use strict";var r=n(26),i=n(3)("iterator"),a=Array.prototype;e.exports=function(e){return void 0!==e&&(r.Array===e||a[i]===e)}},function(e,t,n){"use strict";var r=n(6);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw void 0!==a&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(10),i=n(116),a=n(115),o=n(6),u=n(25),s=n(114),f={},c={},d=e.exports=function(e,t,n,d,l){var h,p,v,m,y=l?function(){return e}:s(e),b=r(n,d,t?2:1),w=0;if("function"!=typeof y)throw TypeError(e+" is not iterable!");if(a(y)){for(h=u(e.length);h>w;w++)if((m=t?b(o(p=e[w])[0],p[1]):b(e[w]))===f||m===c)return m}else for(v=y.call(e);!(p=v.next()).done;)if((m=i(v,b,p.value,t))===f||m===c)return m};d.BREAK=f,d.RETURN=c},function(e,t,n){"use strict";e.exports=function(e,t,n,r){if(!(e instanceof t)||void 0!==r&&r in e)throw TypeError(n+": incorrect invocation!");return e}},function(e,t,n){"use strict";e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){"use strict";var r=n(5);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;if("function"==typeof(n=e.valueOf)&&!r(i=n.call(e)))return i;if(!t&&"function"==typeof(n=e.toString)&&!r(i=n.call(e)))return i;throw TypeError("Can't convert object to primitive value")}},function(e,t,n){"use strict";e.exports=!n(8)&&!n(30)(function(){return 7!=Object.defineProperty(n(29)("div"),"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";var r=n(7),i=n(2),a=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(e.exports=function(e,t){return a[e]||(a[e]=void 0!==t?t:{})})("versions",[]).push({version:r.version,mode:n(35)?"pure":"global",copyright:"© 2018 Denis Pushkarev (zloirock.ru)"})},function(e,t,n){"use strict";var r,i,a,o,u=n(35),s=n(2),f=n(10),c=n(34),d=n(32),l=n(5),h=n(9),p=n(118),v=n(117),m=n(113),y=n(23).set,b=n(110)(),w=n(22),g=n(109),_=n(21),x=n(108),U=s.TypeError,k=s.process,S=k&&k.versions,B=S&&S.v8||"",M=s.Promise,T="process"==c(k),O=function(){},j=i=w.f,E=!!function(){try{var e=M.resolve(1),t=(e.constructor={})[n(3)("species")]=function(e){e(O,O)};return(T||"function"==typeof PromiseRejectionEvent)&&e.then(O)instanceof t&&0!==B.indexOf("6.6")&&-1===_.indexOf("Chrome/66")}catch(e){}}(),z=function(e){var t;return!(!l(e)||"function"!=typeof(t=e.then))&&t},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;b(function(){for(var r=e._v,i=1==e._s,a=0,o=function(t){var n,a,o,u=i?t.ok:t.fail,s=t.resolve,f=t.reject,c=t.domain;try{u?(i||(2==e._h&&D(e),e._h=1),!0===u?n=r:(c&&c.enter(),n=u(r),c&&(c.exit(),o=!0)),n===t.promise?f(U("Promise-chain cycle")):(a=z(n))?a.call(n,s,f):s(n)):f(r)}catch(e){c&&!o&&c.exit(),f(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&P(e)})}},P=function(e){y.call(s,function(){var t,n,r,i=e._v,a=A(e);if(a&&(t=g(function(){T?k.emit("unhandledRejection",i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error("Unhandled promise rejection",i)}),e._h=T||A(e)?2:1),e._a=void 0,a&&t.e)throw t.v})},A=function(e){return 1!==e._h&&0===(e._a||e._c).length},D=function(e){y.call(s,function(){var t;T?k.emit("rejectionHandled",e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},L=function(e){var t=this;t._d||(t._d=!0,(t=t._w||t)._v=e,t._s=2,t._a||(t._a=t._c.slice()),C(t,!0))},R=function e(t){var n,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw U("Promise can't be resolved itself");(n=z(t))?b(function(){var i={_w:r,_d:!1};try{n.call(t,f(e,i,1),f(L,i,1))}catch(e){L.call(i,e)}}):(r._v=t,r._s=1,C(r,!1))}catch(e){L.call({_w:r,_d:!1},e)}}};E||(M=function(e){p(this,M,"Promise","_h"),h(e),r.call(this);try{e(f(R,this,1),f(L,this,1))}catch(e){L.call(this,e)}},(r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=n(107)(M.prototype,{then:function(e,t){var n=j(m(this,M));return n.ok="function"!=typeof e||e,n.fail="function"==typeof t&&t,n.domain=T?k.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),a=function(){var e=new r;this.promise=e,this.resolve=f(R,e,1),this.reject=f(L,e,1)},w.f=j=function(e){return e===M||e===o?new a(e):i(e)}),d(d.G+d.W+d.F*!E,{Promise:M}),n(106)(M,"Promise"),n(105)("Promise"),o=n(7).Promise,d(d.S+d.F*!E,"Promise",{reject:function(e){var t=j(this);return(0,t.reject)(e),t.promise}}),d(d.S+d.F*(u||!E),"Promise",{resolve:function(e){return x(u&&this===o?M:this,e)}}),d(d.S+d.F*!(E&&n(104)(function(e){M.all(e).catch(O)})),"Promise",{all:function(e){var t=this,n=j(t),r=n.resolve,i=n.reject,a=g(function(){var n=[],a=0,o=1;v(e,!1,function(e){var u=a++,s=!1;n.push(void 0),o++,t.resolve(e).then(function(e){s||(s=!0,n[u]=e,--o||r(n))},i)}),--o||r(n)});return a.e&&i(a.v),n.promise},race:function(e){var t=this,n=j(t),r=n.reject,i=g(function(){v(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i.e&&r(i.v),n.promise}})},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n(123),n(103);var i=s(n(19)),a=s(n(100)),o=s(n(36)),u=s(n(16));function s(e){return e&&e.__esModule?e:{default:e}}var f=function(e,t){t.vid=e.config.vid,t.url=e.src,t.errd&&"object"===r(t.errd)&&e.mp4&&(t.errd.url=e.mp4.url,t.url=e.mp4.url,e.mp4.canDownload=!1),e.emit("DATA_REPORT",t),"network"===t.errt&&e.config._backupURL?e.src=e.config._backupURL:e.src=e.config._mainURL,e.switchURL=null,e._replay=null};i.default.install("mp4player",function(){var e=this,t=i.default.sniffer,n=i.default.util,r=i.default.Errors,s=void 0,c=void 0,d=e.config.preloadTime||15,l=void 0,h=e.config.url,p=e.config.pluginRule||function(){return!0};if(h){"String"===n.typeOf(h)?s=h:"Array"===n.typeOf(h)&&h.length&&(s=h[0].src,c=h[1].src),e.config._mainURL=s,e.config._backupURL=c;var v=function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.currentTime;e.timer&&clearTimeout(e.timer),r=Math.max(r,e.currentTime),e.timer=setTimeout(function(){e.mp4.seek(r+.1*n).then(function(t){if(t){var n=e.mse;n.updating=!0,n.appendBuffer(t),n.once("updateend",function(){n.updating=!1})}},function(){n<10&&setTimeout(function(){t(n+1)},2e3)})},50)},m=function(t){var n=new a.default(t),r=void 0;return new Promise(function(t,i){n.once("moovReady",function(){(r=new o.default).on("sourceopen",function(){r.appendBuffer(n.packMeta()),r.once("updateend",v.bind(e))}),r.on("error",function(e){i(e)}),t([n,r])}),n.on("error",function(e){i(e)})})};if(["chrome","firfox","safari"].some(function(e){return e===t.browser})&&o.default.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')){var y=e.start;if(!p.call(e))return!1;Object.defineProperty(e,"src",{get:function(){return e.currentSrc},set:function(t){e.config.url=t,e.paused?e.start(t):(e.pause(),e.once("pause",function(){e.start(t)}),e.once("canplay",function(){e.play()})),e.once("canplay",function(){e.currentTime=0})}}),e.start=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s;m(n).then(function(t){var n=t[0],r=t[1];y.call(e,r.url),e.mp4=n,e.mse=r,n.on("error",function(t){f(e,t)})},function(t){y.call(e,n),f(e,t)}),e.once("canplay",function(){if("safari"===t.browser&&e.buffered){var n=e.buffered.start(0);e.currentTime=n+.1}})},e.switchURL=function(n){var r=new a.default(n),i=e.mp4;r.on("moovReady",function(){i.timeRage;var n=e.currentTime,a=i.timeRage.find(function(e){return e[0]-n>2})[0],o=e.getBufferedRange()[1];o-a>0&&"safari"!==t.browser&&e.mse.removeBuffer(a,o),e.mp4=r,e.mse.appendBuffer(r.packMeta())}),r.on("error",function(t){f(e,t)})},e.on("timeupdate",function(){var t=e.mse,n=e.mp4;if(t&&!t.updating&&n.canDownload){var r=n.timeRage,i=e.getBufferedRange(),a=e.currentTime+d;if(i[1]-a>0)return;r.every(function(e,t){var r=(e[0]+e[1])/2;return 0===i[1]?(v(5),!1):!(r>i[1]&&!n.bufferCache.has(t))||void v(0,r)}),function(e,t){if(t.meta.endTime-e.currentTime<2){var n=e.getBufferedRange();e.currentTime-n[1]<.1&&e.mse.endOfStream()}}(e,n)}}),e.on("seeking",function(){var t=e.buffered,n=!1,r=e.currentTime;if(u.default.clear(),t.length){for(var i=0,a=t.length;i=t.start(i)&&r<=t.end(i)){n=!0;break}n||v(0,r)}else v(0,e.currentTime)}),e.on("pause",function(){u.default.clear()}),e.on("playing",function(){l&&clearTimeout(l)}),e.on("waiting",function(){var t=e.mp4;if(t&&t.meta){var n=e.getBufferedRange(),r=t.meta.videoDuration;r-e.currentTime<.5&&r-n[1]<.5?e.mse.endOfStream():(v(0,n[1]+1),l=setTimeout(function(){for(var t=e.buffered,n=void 0,r=0,i=t.length;r=e.currentTime){e.currentTime=n;break}},1500))}}),e.once("destroy",function(){u.default.clear(),e.timer&&clearTimeout(e.timer)}),e._replay=function(){u.default.clear(),e.mp4.bufferCache.clear(),m(e.mp4.url).then(function(t){var n=t[0],r=t[1];e.src=r.url,e.mp4=n,e.mse=r,e.currentTime=0,e.play()},function(t){f(e,t)})}}}else e.emit("error",new r("other",e.config.vid))})},function(e,t,n){e.exports=n(124)}])}); \ No newline at end of file diff --git a/packages/xgplayer-mp4/src/index.js b/packages/xgplayer-mp4/src/index.js index 093e962a9..254c0a56e 100644 --- a/packages/xgplayer-mp4/src/index.js +++ b/packages/xgplayer-mp4/src/index.js @@ -242,6 +242,13 @@ let mp4player = function () { } }) + player.once('destroy', () => { + Task.clear() + if (player.timer) { + clearTimeout(player.timer) + } + }) + player._replay = function () { Task.clear() player.mp4.bufferCache.clear() diff --git a/packages/xgplayer/browser/index.js b/packages/xgplayer/browser/index.js index 51b1399a6..756dc06b8 100644 --- a/packages/xgplayer/browser/index.js +++ b/packages/xgplayer/browser/index.js @@ -1,4 +1,4 @@ -window.Player=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.config.url,n=this.root,r=this;"String"===a.default.typeOf(t)?this.video.src=t:t.forEach(function(t){e.video.appendChild(a.default.createDom("source","",{src:""+t.src,type:""+(t.type||"")}))}),n.insertBefore(this.video,n.firstChild),r.userTimer=setTimeout(function(){r.emit("blur")},r.config.inactive),setTimeout(function(){e.emit("complete")},1)}},{key:"reload",value:function(){this.video.load(),this.once("loadeddata",function(){this.play()})}},{key:"destroy",value:function(){var e=this,t=this.root.parentNode;this.paused?(this.emit("destroy"),t.removeChild(this.root),t.appendChild(this.rootBackup)):(this.pause(),this.once("pause",function(){e.emit("destroy"),t.removeChild(e.root),t.appendChild(e.rootBackup)})),setTimeout(function(){for(var e in this)"config"!==e&&delete this[e]},200)}},{key:"replay",value:function(){var e=this._replay;a.default.removeClass(this.root,"xgplayer-ended"),e&&e instanceof Function?e():(this.currentTime=0,this.play())}},{key:"onFocus",value:function(){var e=this;a.default.removeClass(this.root,"xgplayer-inactive"),e.userTimer&&clearTimeout(e.userTimer),e.userTimer=setTimeout(function(){e.emit("blur")},e.config.inactive)}},{key:"onBlur",value:function(){this.paused||this.ended||a.default.addClass(this.root,"xgplayer-inactive")}},{key:"onPlay",value:function(){a.default.addClass(this.root,"xgplayer-playing"),a.default.removeClass(this.root,"xgplayer-pause")}},{key:"onPause",value:function(){a.default.addClass(this.root,"xgplayer-pause"),this.userTimer&&clearTimeout(this.userTimer),this.emit("focus")}},{key:"onEnded",value:function(){a.default.addClass(this.root,"xgplayer-ended"),a.default.removeClass(this.root,"xgplayer-playing")}},{key:"onSeeking",value:function(){}},{key:"onSeeked",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading")}},{key:"onWaiting",value:function(){var e=this;e.waitTimer&&clearTimeout(e.waitTimer),e.waitTimer=setTimeout(function(){a.default.addClass(e.root,"xgplayer-isloading")},500)}},{key:"onPlaying",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading xgplayer-nostart xgplayer-pause xgplayer-ended xgplayer-is-error xgplayer-replay"),a.default.addClass(this.root,"xgplayer-playing")}}],[{key:"install",value:function(e,n){t.plugins||(t.plugins={}),t.plugins[e]=n}}]),t}();p.util=a.default,p.sniffer=i.default,p.Errors=l.default,t.default=p,e.exports=t.default},function(e,t,n){"use strict";var r=n(17)();e.exports=function(e){return e!==r&&null!==e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.from=t.from,this.to=t.to,this.easing=t.easing||function(e){return e*e},this.duration=t.duration||150,this.curPath="",this.progress=t.progress,this.state=0}return r(e,[{key:"animate",value:function(){var e=this,t=new Date,n=e.duration,r=null,o=e.path2shapes(e.from),a=e.path2shapes(e.to),i=e._preprocessing(o,a);e.state=1;!function o(){var l=new Date-t;if(l>=n||2===e.state)return r=a,e.progress(r,1),window.cancelAnimationFrame(e.tickId),void(e.state=0);var s=e.easing(l/n);r=e._lerp(i[0],i[1],s),e.progress(r,s),e.tickId=window.requestAnimationFrame(o)}()}},{key:"toSVGString",value:function(e){return e.map(function(e){return e.forEach(function(e,t){t?e.splice(0,2,"C"):(e.splice(2,0,"C"),e.unshift("M"))}),e.map(function(e){return e.join(" ")}).join("")}).join("")}},{key:"start",value:function(){self.animate()}},{key:"stop",value:function(){0!==this.state&&(this.state=2),window.cancelAnimationFrame(self.tickId),this.state=0}},{key:"reverse",value:function(){0!==this.state&&this.stop();var e=this.from;this.from=this.to,this.to=e,this.animate()}},{key:"reset",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.from;0!==this.state&&this.stop(),this.from=t,this.to=e,this.animate()}}]),e}();for(var i in o.default)o.default[i]instanceof Function&&!a.prototype[i]&&(a.prototype[i]=o.default[i]);t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={createDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=document.createElement(e);return o.className=r,o.innerHTML=t,Object.keys(n).forEach(function(t){var r=t,a=n[t];"video"===e||"audio"===e?a&&o.setAttribute(r,a):o.setAttribute(r,a)}),o},hasClass:function(e,t){return e.classList?Array.prototype.some.call(e.classList,function(e){return e===t}):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:function(e,t){e.classList?t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(t){t&&e.classList.add(t)}):r.hasClass(e,t)||(e.className+=" "+t)},removeClass:function(e,t){e.classList?t.split(/\s+/g).forEach(function(t){e.classList.remove(t)}):r.hasClass(e,t)&&t.split(/\s+/g).forEach(function(t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")})},toggleClass:function(e,t){t.split(/\s+/g).forEach(function(t){r.hasClass(e,t)?r.removeClass(e,t):r.addClass(e,t)})},findDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=arguments[1];return e.querySelector(t)},padStart:function(e,t,n){for(var r=String(n),o=t>>0,a=Math.ceil(o/r.length),i=[],l=String(e);a--;)i.push(r);return i.join("").substring(0,o-l.length)+l},format:function(e){if(window.isNaN(e))return"";var t=r.padStart(Math.floor(e/3600),2,0),n=r.padStart(Math.floor((e-3600*t)/60),2,0),o=r.padStart(Math.floor(e-3600*t-60*n),2,0);return("00"===t?[n,o]:[t,n,o]).join(":")},event:function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},typeOf:function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},deepCopy:function(e,t){if("Object"===r.typeOf(t)&&"Object"===r.typeOf(e))return Object.keys(t).forEach(function(n){"Object"!==r.typeOf(t[n])||t[n]instanceof Node?e[n]=t[n]:e[n]?r.deepCopy(e[n],t[n]):e[n]=t[n]}),e},getBgImage:function(e){var t=document.createElement("a"),n=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;return t.href=n.replace(/url\("|"\)/g,""),t.href},copyDom:function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return Array.prototype.forEach.call(e.attributes,function(e){t.setAttribute(e.name,e.value)}),t}return""}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5);var o={network:{code:1,msg:"视频下载错误",remark:"只要视频下载错误就使用此类型,无论是video本身的超时还是xhr的分段请求超时或者资源不存在"},mse:{code:2,msg:"流追加错误",remark:"追加流的时候如果类型不对、无法被正确解码则会触发此类错误"},parse:{code:3,msg:"解析错误",remark:"mp4、hls、flv我们都是使用js进行格式解析,如果解析失败则会触发此类错误"},format:{code:4,msg:"格式错误",remark:"如果浏览器不支持的格式导致播放错误"},decoder:{code:5,msg:"解码错误",remark:"浏览器解码异常会抛出此类型错误"},runtime:{code:6,msg:"语法错误",remark:"播放器语法错误"},timeout:{code:7,msg:"播放超时",remark:"播放过程中无法正常请求下一个分段导致播放中断"},other:{code:8,msg:"其他错误",remark:"不可知的错误或被忽略的错误类型"}};t.default=function e(t,n,a,i,l,s,u,c){var p=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{line:"",handle:"",msg:"",version:""};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var f={};return f.playerVersion=r.version,f.errorType=t,f.domain=document.domain,f.duration=a,f.currentTime=n,f.networkState=i,f.readyState=l,f.currentSrc=u,f.src=s,f.ended=c,f.errd=p,f.ex=(o[t]||{}).msg,f},e.exports=t.default},function(e){e.exports={name:"xgplayer",version:"1.0.7",description:"video player",main:"./dist/index.js",scripts:{prepare:"npm run build",build:"webpack --progress --display-chunks -p",watch:"webpack --progress --display-chunks -p --watch"},keywords:["video","player"],babel:{presets:["es2015"],plugins:["add-module-exports","babel-plugin-bulk-import"]},repository:{type:"git",url:"git+https://github.com/bytedance/xgplayer.git"},author:"yinguohui@bytedance.com",license:"MIT",dependencies:{"babel-plugin-add-module-exports":"^0.2.1",deepmerge:"^1.5.0","event-emitter":"^0.3.5",pasition:"^1.0.1","request-frame":"^1.5.3"},browserslist:["> 5%","IE 9","iOS 7","Firefox > 20"],devDependencies:{"babel-loader":"^7.1.4","babel-plugin-bulk-import":"^1.0.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-preset-es2015":"^6.24.1","core-js":"^2.5.4","css-loader":"^0.28.11","json-loader":"^0.5.7","node-sass":"^4.8.3","postcss-cssnext":"^3.1.0","postcss-loader":"^2.1.5","sass-loader":"^6.0.7","style-loader":"^0.20.3",sugarss:"^1.0.1",webpack:"^4.8.1","webpack-cli":"^2.1.3",zlib:"^1.0.5"}}},function(e,t,n){e.exports=n(7)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=w(n(0)),o=w(n(26)),a=w(n(29)),i=w(n(30)),l=w(n(31)),s=w(n(32)),u=w(n(33)),c=w(n(34)),p=w(n(35)),f=w(n(36)),d=w(n(37)),h=w(n(38)),g=w(n(41)),y=w(n(42)),v=w(n(43)),m=w(n(44)),x=w(n(45)),b=w(n(46));function w(e){return e&&e.__esModule?e:{default:e}}n(47);var k={};function E(e,t,n){var r=e;t.map(function(e,o){r[e]=o==t.length-1?n:r[e]||{},r=r[e]})}E(k,["control","definition"],b.default),E(k,["control","error"],x.default),E(k,["control","flex"],m.default),E(k,["control","fullscreen"],v.default),E(k,["control","i18n"],y.default),E(k,["control","loading"],g.default),E(k,["control","makeBullet"],h.default),E(k,["control","mobile"],d.default),E(k,["control","pc"],f.default),E(k,["control","play"],p.default),E(k,["control","playbackRate"],c.default),E(k,["control","poster"],u.default),E(k,["control","progress"],s.default),E(k,["control","replay"],l.default),E(k,["control","textTrack"],i.default),E(k,["control","time"],a.default),E(k,["control","volume"],o.default),t.default=r.default,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n",!0}),r.crossorigin="anonymous"),t.textTrackStyle){var s=document.createElement("style");document.head.appendChild(s);var u="";for(var c in t.textTrackStyle)u+=c+": "+t.textTrackStyle[c]+";";var p=t.id?"#"+t.id:t.el.id?"#"+t.el.id:"."+t.el.className;s.sheet.addRule(p+" video::cue",u),s.sheet.insertRule(p+" video::cue { "+u+" }",0)}this.video=a.default.createDom(r.mediaType,l,r,""),this.ev=["play","playing","pause","ended","error","seeking","seeked","timeupdate","waiting","canplay","canplaythrough","durationchange","volumechange","loadeddata"].map(function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e,"on"+e.charAt(0).toUpperCase()+e.slice(1))}),(0,o.default)(this),this.ev.forEach(function(e){var t=n,r=Object.keys(e)[0];t.video.addEventListener(r,function(){"play"===r&&(t.hasStart=!0),"error"===r?t.video.error&&t.emit(r,new i.default("other",t.currentTime,t.duration,t.networkState,t.readyState,t.currentSrc,t.src,t.ended,{line:41,msg:t.error,handle:"Constructor"})):t.emit(r,t)},!1)})}return r(e,[{key:"play",value:function(){this.video.play()}},{key:"pause",value:function(){this.video.pause()}},{key:"canPlayType",value:function(){this.video.canPlayType()}},{key:"getBufferedRange",value:function(){var e=[0,0],t=this.video,n=t.buffered,r=t.currentTime;if(n)for(var o=0,a=n.length;o-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={get device(){var e=r.os;return e.isPc?"pc":e.isTablet?"tablet":"mobile"},get browser(){var e=navigator.userAgent.toLowerCase(),t={ie:/rv:([\d.]+)\) like gecko/,firfox:/firefox\/([\d.]+)/,chrome:/chrome\/([\d.]+)/,opera:/opera.([\d.]+)/,safari:/version\/([\d.]+).*safari/};return[].concat(Object.keys(t).filter(function(n){return t[n].test(e)}))[0]},get os(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),n=/(?:SymbianOS)/.test(e)||t,r=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e),a=/(?:iPad|PlayBook)/.test(e)||r&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),i=/(?:iPhone)/.test(e)&&!a;return{isTablet:a,isPhone:i,isAndroid:r,isPc:!i&&!r&&!n,isSymbian:n,isWindowsPhone:t,isFireFox:o}}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("volume",function(){var e=this,t=r.default.util,n=e.config.volume,a={muted:"M920.4 439.808l-108.544-109.056-72.704 72.704 109.568 108.544-109.056 108.544 72.704 72.704 108.032-109.568 108.544 109.056 72.704-72.704-109.568-108.032 109.056-108.544-72.704-72.704-108.032 109.568z",small:"M795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z",large:"M940.632 837.632l-72.192-72.192c65.114-64.745 105.412-154.386 105.412-253.44s-40.299-188.695-105.396-253.424l-0.016-0.016 72.192-72.192c83.639 83.197 135.401 198.37 135.401 325.632s-51.762 242.434-135.381 325.612l-0.020 0.020zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z"},i=function(e){return 0===e?"muted":e<.5?"small":"large"},l=a[i(n)],s=a[i(n)],u=t.createDom("xg-volume",'\n \n \n \n \n \n \n \n \n \n ',{},"xgplayer-volume"),c=e.controls;c.appendChild(u);var p=void 0,f=u.querySelector(".xgplayer-slider"),d=u.querySelector(".xgplayer-bar"),h=u.querySelector(".xgplayer-drag"),g=u.querySelector(".xgplayer-icon");h.style.height=100*e.config.volume+"%";var y=c.querySelectorAll("path")[1],v=new o.default({progress:function(e,t){var n=v.toSVGString(e);y.setAttribute("d",n),l=n},from:l,to:a.large}),m=null;f.volume=e.config.volume,["touchstart","mousedown"].forEach(function(n){d.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),f.focus(),t.event(n),p=d.getBoundingClientRect().height,n.clientX;var r=n.clientY,o=h.getBoundingClientRect().height,a=!1,i=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),a=!0;var i=o-n.clientY+r,l=i/p;h.style.height=i+"px",e.volume=Math.max(Math.min(l,1),.01)},l=function n(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),window.removeEventListener("mousemove",i),window.removeEventListener("touchmove",i),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),m||(m=d.getBoundingClientRect()),!a){var o=m.height-(r.clientY-m.top),l=o/m.height;h.style.height=o+"px",l<=0&&(e.volume>0?h.volume=e.video.volume:l=h.volume),e.volume=Math.max(Math.min(l,1),.01)}f.volume=e.volume,a=!1};return window.addEventListener("mousemove",i),window.addEventListener("touchmove",i),window.addEventListener("mouseup",l),window.addEventListener("touchend",l),!1})}),["touchstart","mousedown"].forEach(function(n){g.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),t.hasClass(f,"xgplayer-none")?(t.removeClass(f,"xgplayer-none"),f.focus()):0===e.volume?e.volume=f.volume:e.volume=0})}),f.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.addClass(f,"xgplayer-none")});var x=null;e.on("volumechange",function(){x&&clearTimeout(x),x=setTimeout(function(){v.reset(a[i(e.volume)],l),l=a[i[e.volume]],p||(p=d.getBoundingClientRect().height||76),h.style.height=e.volume*p+"px"},50)}),e.once("canplay",function(){e.volume=e.config.volume}),e.once("destroy",function(){u=null,h=null})})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(i,l){"object"===a(t)&&void 0!==e?e.exports=l():void 0===(o="function"==typeof(r=l)?r.call(t,n,t,e):r)||(e.exports=o)}(0,function(){var e=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{!r&&l.return&&l.return()}finally{if(o)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),t=2*Math.PI,n=function(e,t,n,r,o,a,i){var l=e.x,s=e.y;return{x:r*(l*=t)-o*(s*=n)+a,y:o*l+r*s+i}},r=function(e,t){var n=4/3*Math.tan(t/4),r=Math.cos(e),o=Math.sin(e),a=Math.cos(e+t),i=Math.sin(e+t);return[{x:r-o*n,y:o+r*n},{x:a+i*n,y:i-a*n},{x:a,y:i}]},o=function(e,t,n,r){var o=e*r-t*n<0?-1:1,a=(e*n+t*r)/(Math.sqrt(e*e+t*t)*Math.sqrt(e*e+t*t));return a>1&&(a=1),a<-1&&(a=-1),o*Math.acos(a)},a=function(a){var i=a.px,l=a.py,s=a.cx,u=a.cy,c=a.rx,p=a.ry,f=a.xAxisRotation,d=void 0===f?0:f,h=a.largeArcFlag,g=void 0===h?0:h,y=a.sweepFlag,v=void 0===y?0:y,m=[];if(0===c||0===p)return[];var x=Math.sin(d*t/360),b=Math.cos(d*t/360),w=b*(i-s)/2+x*(l-u)/2,k=-x*(i-s)/2+b*(l-u)/2;if(0===w&&0===k)return[];c=Math.abs(c),p=Math.abs(p);var E=Math.pow(w,2)/Math.pow(c,2)+Math.pow(k,2)/Math.pow(p,2);E>1&&(c*=Math.sqrt(E),p*=Math.sqrt(E));var C=function(e,n,r,a,i,l,s,u,c,p,f,d){var h=Math.pow(i,2),g=Math.pow(l,2),y=Math.pow(f,2),v=Math.pow(d,2),m=h*g-h*v-g*y;m<0&&(m=0),m/=h*v+g*y;var x=(m=Math.sqrt(m)*(s===u?-1:1))*i/l*d,b=m*-l/i*f,w=p*x-c*b+(e+r)/2,k=c*x+p*b+(n+a)/2,E=(f-x)/i,C=(d-b)/l,_=(-f-x)/i,T=(-d-b)/l,M=o(1,0,E,C),S=o(E,C,_,T);return 0===u&&S>0&&(S-=t),1===u&&S<0&&(S+=t),[w,k,M,S]}(i,l,s,u,c,p,g,v,x,b,w,k),_=e(C,4),T=_[0],M=_[1],S=_[2],A=_[3],R=Math.max(Math.ceil(Math.abs(A)/(t/4)),1);A/=R;for(var L=0;Le-1&&(a-=e),r[a]=o}t.push(r)}return t})(e.length).forEach(function(r){var o=0,a=0;r.forEach(function(n){o+=function(e,t){var n=e[0],r=e[2],o=e[4],a=e[6],i=e[1],l=e[3],s=e[5],u=e[7],c=t[0],p=t[2],f=t[4],d=t[6],h=t[1],g=t[3],y=t[5],v=t[7];return Math.sqrt(Math.pow(c-n,2)+Math.pow(h-i,2))+Math.sqrt(Math.pow(p-r,2)+Math.pow(g-l,2))+Math.sqrt(Math.pow(f-o,2)+Math.pow(y-s,2))+Math.sqrt(Math.pow(d-a,2)+Math.pow(v-u,2))}(e[n],t[a++])}),n.push({index:r,distance:o})}),n.sort(function(e,t){return e.distance-t.distance});var r=[];return n[0].index.forEach(function(t){r.push(e[t])}),r}function p(e,t){var n=[];(function(e){for(var t=[],n=0;n2&&(t.push([n].concat(r.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(r.length==i[o])return r.unshift(n),t.push(r);if(r.lengtho-1&&(r-=o)},f._splitCurves=function(e,t){for(var n=0,r=0;n=e.length-1&&(r=0)}},f._upShapes=function(e,t){for(var n=function(t){var n=[];e[e.length-1].forEach(function(e){n.push(e.slice(0))}),e.push(n)},r=0;rr?f._subShapes(o,a,n-r):nr?n=p)return i(c=n,1),a(c),void cancelAnimationFrame(u);var l=s(t/p);c=f._lerp(r[0],r[1],l),i(c,l),u=requestAnimationFrame(e)}()},f})},function(e,t,n){"use strict";!function(){for(var e=0,t=["webkit","moz"],n=0;n"+(e.currentTime||n(0))+""+(e.duration||n(0))+"",{},"xgplayer-time");e.controls.appendChild(o);var a=function(){o.innerHTML=""+n(e.currentTime||0)+""+n(e.duration)};e.on("durationchange",a),e.on("timeupdate",a),e.once("destroy",function(){e.off("durationchange",a),e.off("timeupdate",a),o=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("textTrack",function(){var e=this,t=r.default.util,n=(r.default.sniffer,t.createDom("xg-textTrack","",{tabindex:7},"xgplayer-textTrack")),o=e.controls,a=e.config.textTrack;a&&a instanceof Array&&a.length>1&&(t.addClass(e.root,"xgplayer-is-textTrack"),e.on("canplay",function(){var t=["
    "];t.push("
  • 关闭
  • "),a.forEach(function(e){t.push("
  • "+e.label+"
  • ")});var r=e.config.lang&&"zh-cn"===e.config.lang?"字幕":"Caption";t.push('

'+r+"

");var i=o.querySelector(".xgplayer-textTrack");i?i.innerHTML=t.join(""):(n.innerHTML=t.join(""),o.appendChild(n))})),["touchstart","click"].forEach(function(r){n.addEventListener(r,function(r){r.preventDefault(),r.stopPropagation();var o=r.target||r.srcElement;if(o&&"li"===o.tagName.toLocaleLowerCase()){Array.prototype.forEach.call(o.parentNode.childNodes,function(e){t.removeClass(e,"textTrack")}),t.addClass(o,"textTrack");var i=e.root.getElementsByTagName("Track");"关闭"===o.innerHTML?i[0].track.mode="hidden":(i[0].track.mode="showing",a.some(function(e){if(e.label===o.innerHTML)return i[0].src=e.src,e.kind&&(i[0].kind=e.kind),i[0].label=e.label,e.srclang&&(i[0].srclang=e.srclang),!0}),e.emit("textTrackChange",o.innerHTML))}else!o||"p"!==o.tagName.toLocaleLowerCase()&&"em"!==o.tagName.toLocaleLowerCase()||(t.addClass(n,"xgplayer-textTrack-active"),n.focus())},!1)}),n.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.removeClass(n,"xgplayer-textTrack-active")}),e.once("destroy",function(){n=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("replay",function(){var e=this,t=r.default.util,n=t.createDom("xg-replay",'\n \n \n \n 重播\n ',{},"xgplayer-replay"),o=e.root,a=n.querySelector(".xgplayer-replay-svg");o.appendChild(n),e.on("ended",function(){n.querySelector(".xgplayer-replay-txt").textContent=e.lang.REPLAY,e.config.loop||t.addClass(o,"replay")}),a.addEventListener("click",function(n){n.preventDefault(),t.removeClass(o,"replay"),e.replay()}),e.once("destroy",function(){a=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("progress",function(){var e=this,t=r.default.util,n=t.createDom("xg-progress",'',{tabindex:1},"xgplayer-progress"),o=void 0;e.controls.appendChild(n);var a=n.querySelector(".xgplayer-progress-played"),i=n.querySelector(".xgplayer-progress-cache"),l=n.querySelector(".xgplayer-progress-point"),s=n.querySelector(".xgplayer-progress-thumbnail"),u=0,c=0,p=0,f=0,d=0,h=0,g=[];e.config.thumbnail&&(u=e.config.thumbnail.pic_num,c=e.config.thumbnail.width,p=e.config.thumbnail.height,f=e.config.thumbnail.col,d=e.config.thumbnail.row,g=e.config.thumbnail.urls,s.style.width=c+"px",s.style.height=p+"px"),["touchstart","mousedown"].forEach(function(r){n.addEventListener(r,function(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),r._target===l||e.ended)return!1;n.focus(),o=n.getBoundingClientRect().width;var i=a.getBoundingClientRect().left,s=!1,u=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),s=!0;var r=n.clientX-i,l=r/o*e.duration;a.style.width=100*r/o+"%",e.currentTime=Number(l).toFixed(1)},c=function r(l){if(l.preventDefault(),l.stopPropagation(),t.event(l),window.removeEventListener("mousemove",u),window.removeEventListener("touchmove",u),window.removeEventListener("mouseup",r),window.removeEventListener("touchend",r),n.blur(),!s){var c=l.clientX-i,p=c/o*e.duration;a.style.width=100*c/o+"%",e.currentTime=Number(p).toFixed(1)}s=!1};return window.addEventListener("mousemove",u),window.addEventListener("touchmove",u),window.addEventListener("mouseup",c),window.addEventListener("touchend",c),!1})}),n.addEventListener("mouseenter",function(r){if(e.ended)return!1;var o=n.getBoundingClientRect().left,a=n.getBoundingClientRect().width,i=function(n){var r=(n.clientX-o)/a*e.duration;l.textContent=t.format(r);var i=l.getBoundingClientRect().width;if(e.config.thumbnail){h=e.duration/u;var y=Math.floor(r/h);s.style.backgroundImage="url("+g[Math.ceil((y+1)/(f*d))-1]+")";var v=y+1-f*d*(Math.ceil((y+1)/(f*d))-1),m=Math.ceil(v/d)-1,x=v-m*d-1;s.style["background-position"]="-"+x*c+"px -"+m*p+"px";var b=n.clientX-o-c/2;b=(b=b>0?b:0)0?w:0)>a-i?a-i:w,l.style.left=w+"px"}l.style.display="block"},y=function(e){i(e)};n.addEventListener("mousemove",y,!1),n.addEventListener("mouseleave",function e(t){n.removeEventListener("mousemove",y,!1),n.removeEventListener("mouseleave",e,!1),i(t),l.style.display="none",s.style.display="none"},!1),i(r)},!1),e.on("timeupdate",function(){!o&&n&&(o=n.getBoundingClientRect().width),a.style.width=100*e.currentTime/e.duration+"%"}),["cacheupdate","ended","timeupdate"].forEach(function(t){e.on(t,function(){var t=e.buffered;if(t&&t.length>0){var n=t.end(t.length-1);i.style.width=n/e.duration*100+"%"}})}),e.once("destroy",function(){n=null,a=null,l=null,s=null,i=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("poster",function(){var e=r.default.util.createDom("xg-poster","",{},"xgplayer-poster"),t=this.root;this.config.poster&&(e.style.backgroundImage="url("+this.config.poster+")",t.appendChild(e)),this.on("play",function(){e.style.display="none"}),this.once("destroy",function(){e=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("playbackRate",function(){var e=this,t=r.default.util,n=0,o=[];if(!e.config.playbackRate)return!1;e.config.playbackRate.sort(function(e,t){return e-t}),e.config.playbackRate.forEach(function(e,t){1!==e&&"1"!==e||(n=t),o.push(e+"x")});var a=e.config.lang&&"zh-cn"===e.config.lang?"倍速":"Speed",i=t.createDom("xg-playback",'

1x

',{},"xgplayer-playback"),l=e.controls,s=t.createDom("xg-tips",a,{},"xgplayer-tips");i.appendChild(s),l.appendChild(i),["touchstart","click"].forEach(function(t){i.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation();var r=t.target||t.srcElement;(r&&"p"===r.tagName.toLocaleLowerCase()||"span"===r.tagName.toLocaleLowerCase())&&(n=n+1===o.length?0:n+1,i.querySelector("p").innerHTML=""+o[n]+"",e.video.playbackRate=1*o[n].replace(/x$/g,""))},!1)}),i.addEventListener("mouseenter",function(t){t.preventDefault(),t.stopPropagation(),s.style.left="50%";var n=s.getBoundingClientRect(),r=e.root.getBoundingClientRect();n.right>r.right&&(s.style.left=-n.right+r.right+16+"px")}),e.once("destroy",function(){i=null})})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("play",function(){var e=this,t=e.controls,n=r.default.util,a=e.config.iconScale||.0320625,i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=n.createDom("xg-play",'\n \n '),u=e.config.lang&&"zh-cn"===e.config.lang?"播放":"Play",c=e.config.lang&&"zh-cn"===e.config.lang?"暂停":"Pause",p=n.createDom("xg-tips",u,{},"xgplayer-tips"),f=s.querySelector("path");s.appendChild(p);var d=new o.default({progress:function(e,t){f.setAttribute("d",d.toSVGString(e))},from:l,to:i});s.className="xgplayer-play",t.appendChild(s),["click","touchstart"].forEach(function(t){s.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.ended||(e.paused?e.play():e.pause())},!1)}),e.on("play",function(){p.textContent=c,d.to!==l&&d.reset(l,i)}),e.on("pause",function(){p.textContent=u,d.to!==i&&d.reset(i,l)}),e.once("destroy",function(){s=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("pc",function(){var e=this,t=r.default.util,n=e.controls,o=e.root,a=0,i=void 0,l="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",s="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",u=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),c=t.createDom("xg-enter",'',{},"xgplayer-enter"),p=c.querySelector(".xgplayer-enter-logo");o.appendChild(u),o.appendChild(c);var f=u.querySelector("path"),d=new Image;d.onload=function(){c.querySelector(".xgplayer-enter-tips").style.display="block"},e.config.enterLogo?(d.src=e.config.enterLogo,p.style.backgroundImage='url("'+e.config.enterLogo+'")'):d.src=t.getBgImage(p),["click","touchstart"].forEach(function(n){u.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),e.config.url&&(t.hasClass(o,"xgplayer-nostart")?(t.removeClass(o,"xgplayer-nostart"),t.addClass(o,"xgplayer-is-enter"),o.querySelector("video")||e.start(),e.on("canplay",function(){t.removeClass(o,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(o,"xgplayer-is-enter")}),e.play(),setTimeout(function(){e.play()},10)):e.paused&&(t.removeClass(o,"xgplayer-nostart xgplayer-isloading"),setTimeout(function(){e.play()},10)))})}),u.addEventListener("animationend",function(e){e.preventDefault(),t.removeClass(u,"xgplayer-start-interact"),u.style.display="none"}),e.on("play",function(){f.setAttribute("d",l),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.on("pause",function(){f.setAttribute("d",s),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.video.addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),document.activeElement===e.video?(a++,i&&clearTimeout(i),1===a?i=setTimeout(function(){if(t.hasClass(e.root,"xgplayer-nostart"))return!1;e.ended||(e.paused?e.play():e.pause()),a=0},200):a=0):e.video.focus()},!1),e.video.addEventListener("dblclick",function(t){if(t.preventDefault(),t.stopPropagation(),document.activeElement===e.video){var r=n.querySelector(".xgplayer-fullscreen");if(r){var o=void 0;document.createEvent?(o=document.createEvent("Event")).initEvent("click",!0,!0):o=new Event("click"),r.dispatchEvent(o)}}else e.video.focus()},!1),o.addEventListener("mouseenter",function(t){e.emit("focus",e)},!1),o.addEventListener("mouseleave",function(t){e.emit("blur",e)},!1),n.addEventListener("mouseenter",function(t){e.userTimer&&clearTimeout(e.userTimer)},!1),n.addEventListener("mouseleave",function(t){e.emit("focus",e)},!1)})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("mobile",function(){var e=this,t=r.default.util,n=e.root;e.config.autoplay=!1;var a=function(e){var t=r.default.util;return e.some(function(e){return"Function"===t.typeOf(e)?e.call(navigator.userAgent):"RegExp"===t.typeOf(e)?e.test(navigator.userAgent):"String"===t.typeOf(e)&&navigator.userAgent.indexOf(e)>-1})}(e.config.whitelist);e.mobilePass=a;var i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),u=t.createDom("xg-enter",'',{},"xgplayer-enter"),c=u.querySelector(".xgplayer-enter-logo");n.appendChild(s),n.appendChild(u);var p=s.querySelector("path"),f=new Image,d=new o.default({from:l,to:i,progress:function(e,t){p.setAttribute("d",d.toSVGString(e))}});u.querySelector(".xgplayer-enter-tips").style.display="block",e.start(),a?(e.config.enterLogo?(f.src=e.config.enterLogo,c.style.backgroundImage='url("'+e.config.enterLogo+'")'):f.src=t.getBgImage(c),e.video.addEventListener("touchstart",function(t){t.preventDefault(),e.emit("focus")},!1),s.addEventListener("touchend",function(r){r.preventDefault(),t.hasClass(n,"xgplayer-nostart")?(t.removeClass(n,"xgplayer-nostart"),t.addClass(n,"xgplayer-is-enter"),e.on("canplay",function(){t.removeClass(n,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(n,"xgplayer-is-enter")}),e.play()):e.paused?e.play():e.pause()}),e.on("play",function(){d.reset(l,i)}),e.on("pause",function(){d.reset(i,l)})):(t.addClass(n,"xgplayer-mobile-npassed"),e.once("ready",function(){e.video.controls=e.config.controls,e.video.controlsList=e.config.controlsList.join(" "),e.config.poster&&(e.video.poster=e.config.poster)})),e.config.debug&&function(e){var t={};Object.assign(t,{host:"127.0.0.1",port:9090},e);var n=document.createElement("script"),r=document.createElement("h4");r.style.cssText="position:fixed;bottom:0;padding:10px;width:100%;background-color:#fff;text-align:center",r.textContent="weinre --boundHost "+t.host+" --httpPort "+t.port+"\r\n 启动服务后,刷新页面",n.anonymous=!0,n.async=!0,n.src="http://"+t.host+":"+t.port+"/target/target-script-min.js#anonymous",n.onload=function(){r.parentNode.removeChild(r)},document.body.appendChild(n),document.body.appendChild(r)}(e.config.debug)})},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;ni.length){for(var c=function(e){i[e]={id:e,queue:[],step:t.channels[e].step,surplus:t.channels[e].surplus},t.channels[e].queue.forEach(function(t){return i[e].queue.push(t)})},p=0;pn.length)return{result:!1,message:"exceed channels.length, occupy="+o+",channelsSize="+n.length};for(var a=!0,i=void 0,l=-1,s=0,u=n.length;s-1&&(r.queue.splice(i,1),0===i&&(r.step=9999,r.surplus=0))}}},{key:"update",value:function(){var e=this.channels,t=this.width;e.forEach(function(e){var n=e.queue[0];n?e.surplus=t-n.left-n.width:(e.step=9999,e.surplus=0)})}},{key:"reset",value:function(){var e=this.player.root,t=this;setTimeout(function(){var n=e.querySelector(".xgplayer-bullet"),r=n.getBoundingClientRect();t.width=r.width,t.height=r.height,t.container=n;for(var o=/mobile/gi.test(navigator.userAgent)?10:12,a=Math.floor(t.height/o),i=[],l=0;l0?e.map(function(e){return{id:e.danmaku_id,txt:e.text.slice(0,40),duration:1*e.duration,color:e.text_color.replace("0x","#"),scale:1*e.text_scale,start:1*e.offset_time}}):[]}},n),t.on("dataIncoming",this.dataHandle.bind(this)),t.on("seeked",this.seekHandle.bind(this)),t.on("bullet_remove",this.updateQueue.bind(this)),t.on("ended",this.stop.bind(this)),t.on("pause",this.pause.bind(this)),t.on("play",this.play.bind(this))}return r(e,[{key:"updateQueue",value:function(e){var t=this;t.queue.some(function(n,r){if(n.id===e.bullet.id)return t.queue.splice(r,1),!0})}},{key:"init",value:function(){var e=this;if(e.data)return e.player.paused?void(e.status="paused"):e.player.ended?void(e.status="ended"):(e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),void e.player.emit("dataIncoming"));fetch(e.options.url,{method:e.options.method,headers:{Accept:"application/json"}}).then(function(t){t.ok&&t.json().then(function(t){var n=e.options.dataMap.call(null,t.data);if(n.length){e.data=n;var r=document.createElement("span");r.style.padding=e.options.padding+"||'0px'",r.style.position="absolute",r.style.left="-99999px",document.body.appendChild(r);var o=void 0;if(e.data.forEach(function(e){r.textContent=e.txt,r.style.fontSize=20*e.scale+"px",o=r.getBoundingClientRect(),e.width=o.width,e.height=o.height}),e.data.sort(function(e,t){return e.start-t.start}),document.body.removeChild(r),e.player.paused)return void(e.status="paused");if(e.player.ended)return void(e.status="ended");e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),e.player.emit("dataIncoming")}})}).catch(function(e){console.log("Fetch错误:"+e)})}},{key:"start",value:function(){this.status="playing",this.channel.reset(),this.init()}},{key:"stop",value:function(){this.status="closed",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer),this.queue.length=0,this.container.innerHTML=""}},{key:"play",value:function(){var e=this,t=o.default.util;"idle"===e.status||"ended"===e.status?t.hasClass(e.container,"xgplayer-has-bullet")&&e.start():"paused"===e.status&&t.hasClass(e.container,"xgplayer-has-bullet")&&(e.status="playing",e.dataHandle(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3))}},{key:"pause",value:function(){"playing"===this.status?(this.status="paused",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer)):"ended"===this.status&&this.stop()}},{key:"dataHandle",value:function(){var e=(0,a.default)("cancel");if(e(this.timer),this.queue.length){this.queue.forEach(function(e){"waiting"!==e.status&&"start"!==e.status||(e.status="start",e.move())});var t=(0,a.default)("request");this.timer=t(this.dataHandle.bind(this))}else e(this.timer)}},{key:"readData",value:function(){var e=this,t=this.player,n=this.formatTime(t.currentTime),r=void 0,o=e.interval,a=e.channel,i=e.container,l=e.data.filter(function(e){return e.start<=n&&n<=e.start+o});l.length>0&&l.forEach(function(n){r=new c(t,i,n),a.addBullet(r).result&&(e.queue.push(r),r.reset(),r.attach())})}},{key:"seekHandle",value:function(){o.default.util;this.stop(),this.player.paused?this.status="idle":(this.status="playing",this.channel.resetWithCb(),this.init())}},{key:"formatTime",value:function(e){var t=Math.floor(e);return 1e3*t+(e-t)}}]),e}(),f=function(){function e(t,n){s(this,e);var r=this;this.player=t,this.el_=this.createEl(),this.onceFlag=!1;["click","touchstart"].forEach(function(e){r.el_.addEventListener(e,function(e){e.preventDefault(),e.stopPropagation(),r.onClick()},!1)}),this.main=new p(t,n),"on"===n.switch&&this.player.once("play",function(){r.onChange(!0)})}return r(e,[{key:"createEl",value:function(){return o.default.util.createDom("xg-bullet-btn",'',{},"xgplayer-bullet-btn "+("on"===this.player.config.bullet.switch?"xgplayer-bullet-btn-active":""))}},{key:"onClick",value:function(){var e=this,t=o.default.util;t.toggleClass(e.el_,"xgplayer-bullet-btn-active");var n=!!t.hasClass(e.el_,"xgplayer-bullet-btn-active");function r(){e.onceFlag=!1,e.main.channel.resetWithCb(e.onChange.bind(e))}n?e.player.paused||e.player.ended?this.onceFlag||(this.onceFlag=!0,this.player.once("play",r)):r():(this.player.off("play",r),this.onChange(n))}},{key:"onChange",value:function(e){var t=o.default.util,n=this.player.root.querySelector(".xgplayer-bullet");e?(t.addClass(n,"xgplayer-has-bullet"),this.main.start()):(t.removeClass(n,"xgplayer-has-bullet"),this.main.stop())}}]),e}();o.default.install("makeBullet",function(){var e=this,t=o.default.util;if(e.config.bullet){var n=t.createDom("xg-bullet","",{},"xgplayer-bullet");e.root.appendChild(n);var r=new f(e,e.config.bullet);["touchstart","click"].forEach(function(t){n.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.paused?e.play():e.pause()},!1)}),e.controls.appendChild(r.el_)}})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}; +window.Player=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.config.url,n=this.root,r=this;"String"===a.default.typeOf(t)?this.video.src=t:t.forEach(function(t){e.video.appendChild(a.default.createDom("source","",{src:""+t.src,type:""+(t.type||"")}))}),n.insertBefore(this.video,n.firstChild),r.userTimer=setTimeout(function(){r.emit("blur")},r.config.inactive),setTimeout(function(){e.emit("complete")},1)}},{key:"reload",value:function(){this.video.load(),this.once("loadeddata",function(){this.play()})}},{key:"destroy",value:function(){var e=this,t=this.root.parentNode;if(this.ev.forEach(function(t){var n=Object.keys(t)[0],r=e[t[n]];r&&e.off(n,r)}),["focus","blur"].forEach(function(t){e.off(t,e["on"+t.charAt(0).toUpperCase()+t.slice(1)])}),this.paused)for(var n in this.emit("destroy"),t.removeChild(this.root),t.appendChild(this.rootBackup),this)"config"!==n&&delete this[n];else this.pause(),this.once("pause",function(){for(var n in e.emit("destroy"),t.removeChild(e.root),t.appendChild(e.rootBackup),e)"config"!==n&&delete e[n]})}},{key:"replay",value:function(){var e=this._replay;a.default.removeClass(this.root,"xgplayer-ended"),e&&e instanceof Function?e():(this.currentTime=0,this.play())}},{key:"onFocus",value:function(){var e=this;a.default.removeClass(this.root,"xgplayer-inactive"),e.userTimer&&clearTimeout(e.userTimer),e.userTimer=setTimeout(function(){e.emit("blur")},e.config.inactive)}},{key:"onBlur",value:function(){this.paused||this.ended||a.default.addClass(this.root,"xgplayer-inactive")}},{key:"onPlay",value:function(){a.default.addClass(this.root,"xgplayer-playing"),a.default.removeClass(this.root,"xgplayer-pause")}},{key:"onPause",value:function(){a.default.addClass(this.root,"xgplayer-pause"),this.userTimer&&clearTimeout(this.userTimer),this.emit("focus")}},{key:"onEnded",value:function(){a.default.addClass(this.root,"xgplayer-ended"),a.default.removeClass(this.root,"xgplayer-playing")}},{key:"onSeeking",value:function(){}},{key:"onSeeked",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading")}},{key:"onWaiting",value:function(){var e=this;e.waitTimer&&clearTimeout(e.waitTimer),e.waitTimer=setTimeout(function(){a.default.addClass(e.root,"xgplayer-isloading")},500)}},{key:"onPlaying",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading xgplayer-nostart xgplayer-pause xgplayer-ended xgplayer-is-error xgplayer-replay"),a.default.addClass(this.root,"xgplayer-playing")}}],[{key:"install",value:function(e,n){t.plugins||(t.plugins={}),t.plugins[e]=n}}]),t}();p.util=a.default,p.sniffer=i.default,p.Errors=l.default,t.default=p,e.exports=t.default},function(e,t,n){"use strict";var r=n(17)();e.exports=function(e){return e!==r&&null!==e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.from=t.from,this.to=t.to,this.easing=t.easing||function(e){return e*e},this.duration=t.duration||150,this.curPath="",this.progress=t.progress,this.state=0}return r(e,[{key:"animate",value:function(){var e=this,t=new Date,n=e.duration,r=null,o=e.path2shapes(e.from),a=e.path2shapes(e.to),i=e._preprocessing(o,a);e.state=1;!function o(){var l=new Date-t;if(l>=n||2===e.state)return r=a,e.progress(r,1),window.cancelAnimationFrame(e.tickId),void(e.state=0);var s=e.easing(l/n);r=e._lerp(i[0],i[1],s),e.progress(r,s),e.tickId=window.requestAnimationFrame(o)}()}},{key:"toSVGString",value:function(e){return e.map(function(e){return e.forEach(function(e,t){t?e.splice(0,2,"C"):(e.splice(2,0,"C"),e.unshift("M"))}),e.map(function(e){return e.join(" ")}).join("")}).join("")}},{key:"start",value:function(){self.animate()}},{key:"stop",value:function(){0!==this.state&&(this.state=2),window.cancelAnimationFrame(self.tickId),this.state=0}},{key:"reverse",value:function(){0!==this.state&&this.stop();var e=this.from;this.from=this.to,this.to=e,this.animate()}},{key:"reset",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.from;0!==this.state&&this.stop(),this.from=t,this.to=e,this.animate()}}]),e}();for(var i in o.default)o.default[i]instanceof Function&&!a.prototype[i]&&(a.prototype[i]=o.default[i]);t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={createDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=document.createElement(e);return o.className=r,o.innerHTML=t,Object.keys(n).forEach(function(t){var r=t,a=n[t];"video"===e||"audio"===e?a&&o.setAttribute(r,a):o.setAttribute(r,a)}),o},hasClass:function(e,t){return e.classList?Array.prototype.some.call(e.classList,function(e){return e===t}):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:function(e,t){e.classList?t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(t){t&&e.classList.add(t)}):r.hasClass(e,t)||(e.className+=" "+t)},removeClass:function(e,t){e.classList?t.split(/\s+/g).forEach(function(t){e.classList.remove(t)}):r.hasClass(e,t)&&t.split(/\s+/g).forEach(function(t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")})},toggleClass:function(e,t){t.split(/\s+/g).forEach(function(t){r.hasClass(e,t)?r.removeClass(e,t):r.addClass(e,t)})},findDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=arguments[1];return e.querySelector(t)},padStart:function(e,t,n){for(var r=String(n),o=t>>0,a=Math.ceil(o/r.length),i=[],l=String(e);a--;)i.push(r);return i.join("").substring(0,o-l.length)+l},format:function(e){if(window.isNaN(e))return"";var t=r.padStart(Math.floor(e/3600),2,0),n=r.padStart(Math.floor((e-3600*t)/60),2,0),o=r.padStart(Math.floor(e-3600*t-60*n),2,0);return("00"===t?[n,o]:[t,n,o]).join(":")},event:function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},typeOf:function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},deepCopy:function(e,t){if("Object"===r.typeOf(t)&&"Object"===r.typeOf(e))return Object.keys(t).forEach(function(n){"Object"!==r.typeOf(t[n])||t[n]instanceof Node?e[n]=t[n]:e[n]?r.deepCopy(e[n],t[n]):e[n]=t[n]}),e},getBgImage:function(e){var t=document.createElement("a"),n=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;return t.href=n.replace(/url\("|"\)/g,""),t.href},copyDom:function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return Array.prototype.forEach.call(e.attributes,function(e){t.setAttribute(e.name,e.value)}),t}return""}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5);var o={network:{code:1,msg:"视频下载错误",remark:"只要视频下载错误就使用此类型,无论是video本身的超时还是xhr的分段请求超时或者资源不存在"},mse:{code:2,msg:"流追加错误",remark:"追加流的时候如果类型不对、无法被正确解码则会触发此类错误"},parse:{code:3,msg:"解析错误",remark:"mp4、hls、flv我们都是使用js进行格式解析,如果解析失败则会触发此类错误"},format:{code:4,msg:"格式错误",remark:"如果浏览器不支持的格式导致播放错误"},decoder:{code:5,msg:"解码错误",remark:"浏览器解码异常会抛出此类型错误"},runtime:{code:6,msg:"语法错误",remark:"播放器语法错误"},timeout:{code:7,msg:"播放超时",remark:"播放过程中无法正常请求下一个分段导致播放中断"},other:{code:8,msg:"其他错误",remark:"不可知的错误或被忽略的错误类型"}};t.default=function e(t,n,a,i,l,s,u,c){var p=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{line:"",handle:"",msg:"",version:""};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var f={};return f.playerVersion=r.version,f.errorType=t,f.domain=document.domain,f.duration=a,f.currentTime=n,f.networkState=i,f.readyState=l,f.currentSrc=u,f.src=s,f.ended=c,f.errd=p,f.ex=(o[t]||{}).msg,f},e.exports=t.default},function(e){e.exports={name:"xgplayer",version:"1.0.7",description:"video player",main:"./dist/index.js",scripts:{prepare:"npm run build",build:"webpack --progress --display-chunks -p",watch:"webpack --progress --display-chunks -p --watch"},keywords:["video","player"],babel:{presets:["es2015"],plugins:["add-module-exports","babel-plugin-bulk-import"]},repository:{type:"git",url:"git+https://github.com/bytedance/xgplayer.git"},author:"yinguohui@bytedance.com",license:"MIT",dependencies:{"babel-plugin-add-module-exports":"^0.2.1",deepmerge:"^1.5.0","event-emitter":"^0.3.5",pasition:"^1.0.1","request-frame":"^1.5.3"},browserslist:["> 5%","IE 9","iOS 7","Firefox > 20"],devDependencies:{"babel-loader":"^7.1.4","babel-plugin-bulk-import":"^1.0.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-preset-es2015":"^6.24.1","core-js":"^2.5.4","css-loader":"^0.28.11","json-loader":"^0.5.7","node-sass":"^4.8.3","postcss-cssnext":"^3.1.0","postcss-loader":"^2.1.5","sass-loader":"^6.0.7","style-loader":"^0.20.3",sugarss:"^1.0.1",webpack:"^4.8.1","webpack-cli":"^2.1.3",zlib:"^1.0.5"}}},function(e,t,n){e.exports=n(7)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=w(n(0)),o=w(n(26)),a=w(n(29)),i=w(n(30)),l=w(n(31)),s=w(n(32)),u=w(n(33)),c=w(n(34)),p=w(n(35)),f=w(n(36)),d=w(n(37)),h=w(n(38)),g=w(n(41)),y=w(n(42)),v=w(n(43)),m=w(n(44)),x=w(n(45)),b=w(n(46));function w(e){return e&&e.__esModule?e:{default:e}}n(47);var k={};function E(e,t,n){var r=e;t.map(function(e,o){r[e]=o==t.length-1?n:r[e]||{},r=r[e]})}E(k,["control","definition"],b.default),E(k,["control","error"],x.default),E(k,["control","flex"],m.default),E(k,["control","fullscreen"],v.default),E(k,["control","i18n"],y.default),E(k,["control","loading"],g.default),E(k,["control","makeBullet"],h.default),E(k,["control","mobile"],d.default),E(k,["control","pc"],f.default),E(k,["control","play"],p.default),E(k,["control","playbackRate"],c.default),E(k,["control","poster"],u.default),E(k,["control","progress"],s.default),E(k,["control","replay"],l.default),E(k,["control","textTrack"],i.default),E(k,["control","time"],a.default),E(k,["control","volume"],o.default),t.default=r.default,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n",!0}),r.crossorigin="anonymous"),t.textTrackStyle){var s=document.createElement("style");document.head.appendChild(s);var u="";for(var c in t.textTrackStyle)u+=c+": "+t.textTrackStyle[c]+";";var p=t.id?"#"+t.id:t.el.id?"#"+t.el.id:"."+t.el.className;s.sheet.addRule(p+" video::cue",u),s.sheet.insertRule(p+" video::cue { "+u+" }",0)}this.video=a.default.createDom(r.mediaType,l,r,""),this.ev=["play","playing","pause","ended","error","seeking","seeked","timeupdate","waiting","canplay","canplaythrough","durationchange","volumechange","loadeddata"].map(function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e,"on"+e.charAt(0).toUpperCase()+e.slice(1))}),(0,o.default)(this),this.ev.forEach(function(e){var t=n,r=Object.keys(e)[0];t.video.addEventListener(r,function(){"play"===r&&(t.hasStart=!0),"error"===r?t.video.error&&t.emit(r,new i.default("other",t.currentTime,t.duration,t.networkState,t.readyState,t.currentSrc,t.src,t.ended,{line:41,msg:t.error,handle:"Constructor"})):t.emit(r,t)},!1)})}return r(e,[{key:"play",value:function(){this.video.play()}},{key:"pause",value:function(){this.video.pause()}},{key:"canPlayType",value:function(){this.video.canPlayType()}},{key:"getBufferedRange",value:function(){var e=[0,0],t=this.video,n=t.buffered,r=t.currentTime;if(n)for(var o=0,a=n.length;o-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={get device(){var e=r.os;return e.isPc?"pc":e.isTablet?"tablet":"mobile"},get browser(){var e=navigator.userAgent.toLowerCase(),t={ie:/rv:([\d.]+)\) like gecko/,firfox:/firefox\/([\d.]+)/,chrome:/chrome\/([\d.]+)/,opera:/opera.([\d.]+)/,safari:/version\/([\d.]+).*safari/};return[].concat(Object.keys(t).filter(function(n){return t[n].test(e)}))[0]},get os(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),n=/(?:SymbianOS)/.test(e)||t,r=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e),a=/(?:iPad|PlayBook)/.test(e)||r&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),i=/(?:iPhone)/.test(e)&&!a;return{isTablet:a,isPhone:i,isAndroid:r,isPc:!i&&!r&&!n,isSymbian:n,isWindowsPhone:t,isFireFox:o}}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("volume",function(){var e=this,t=r.default.util,n=e.config.volume,a={muted:"M920.4 439.808l-108.544-109.056-72.704 72.704 109.568 108.544-109.056 108.544 72.704 72.704 108.032-109.568 108.544 109.056 72.704-72.704-109.568-108.032 109.056-108.544-72.704-72.704-108.032 109.568z",small:"M795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z",large:"M940.632 837.632l-72.192-72.192c65.114-64.745 105.412-154.386 105.412-253.44s-40.299-188.695-105.396-253.424l-0.016-0.016 72.192-72.192c83.639 83.197 135.401 198.37 135.401 325.632s-51.762 242.434-135.381 325.612l-0.020 0.020zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z"},i=function(e){return 0===e?"muted":e<.5?"small":"large"},l=a[i(n)],s=a[i(n)],u=t.createDom("xg-volume",'\n \n \n \n \n \n \n \n \n \n ',{},"xgplayer-volume"),c=e.controls;c.appendChild(u);var p=void 0,f=u.querySelector(".xgplayer-slider"),d=u.querySelector(".xgplayer-bar"),h=u.querySelector(".xgplayer-drag"),g=u.querySelector(".xgplayer-icon");h.style.height=100*e.config.volume+"%";var y=c.querySelectorAll("path")[1],v=new o.default({progress:function(e,t){var n=v.toSVGString(e);y.setAttribute("d",n),l=n},from:l,to:a.large}),m=null;f.volume=e.config.volume,["touchstart","mousedown"].forEach(function(n){d.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),f.focus(),t.event(n),p=d.getBoundingClientRect().height,n.clientX;var r=n.clientY,o=h.getBoundingClientRect().height,a=!1,i=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),a=!0;var i=o-n.clientY+r,l=i/p;h.style.height=i+"px",e.volume=Math.max(Math.min(l,1),.01)},l=function n(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),window.removeEventListener("mousemove",i),window.removeEventListener("touchmove",i),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),m||(m=d.getBoundingClientRect()),!a){var o=m.height-(r.clientY-m.top),l=o/m.height;h.style.height=o+"px",l<=0&&(e.volume>0?h.volume=e.video.volume:l=h.volume),e.volume=Math.max(Math.min(l,1),.01)}f.volume=e.volume,a=!1};return window.addEventListener("mousemove",i),window.addEventListener("touchmove",i),window.addEventListener("mouseup",l),window.addEventListener("touchend",l),!1})}),["touchstart","mousedown"].forEach(function(n){g.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),t.hasClass(f,"xgplayer-none")?(t.removeClass(f,"xgplayer-none"),f.focus()):0===e.volume?e.volume=f.volume:e.volume=0})}),f.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.addClass(f,"xgplayer-none")});var x=null;e.on("volumechange",function(){x&&clearTimeout(x),x=setTimeout(function(){v.reset(a[i(e.volume)],l),l=a[i[e.volume]],p||(p=d.getBoundingClientRect().height||76),h.style.height=e.volume*p+"px"},50)}),e.once("canplay",function(){e.volume=e.config.volume}),e.once("destroy",function(){u=null,h=null})})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(i,l){"object"===a(t)&&void 0!==e?e.exports=l():void 0===(o="function"==typeof(r=l)?r.call(t,n,t,e):r)||(e.exports=o)}(0,function(){var e=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{!r&&l.return&&l.return()}finally{if(o)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),t=2*Math.PI,n=function(e,t,n,r,o,a,i){var l=e.x,s=e.y;return{x:r*(l*=t)-o*(s*=n)+a,y:o*l+r*s+i}},r=function(e,t){var n=4/3*Math.tan(t/4),r=Math.cos(e),o=Math.sin(e),a=Math.cos(e+t),i=Math.sin(e+t);return[{x:r-o*n,y:o+r*n},{x:a+i*n,y:i-a*n},{x:a,y:i}]},o=function(e,t,n,r){var o=e*r-t*n<0?-1:1,a=(e*n+t*r)/(Math.sqrt(e*e+t*t)*Math.sqrt(e*e+t*t));return a>1&&(a=1),a<-1&&(a=-1),o*Math.acos(a)},a=function(a){var i=a.px,l=a.py,s=a.cx,u=a.cy,c=a.rx,p=a.ry,f=a.xAxisRotation,d=void 0===f?0:f,h=a.largeArcFlag,g=void 0===h?0:h,y=a.sweepFlag,v=void 0===y?0:y,m=[];if(0===c||0===p)return[];var x=Math.sin(d*t/360),b=Math.cos(d*t/360),w=b*(i-s)/2+x*(l-u)/2,k=-x*(i-s)/2+b*(l-u)/2;if(0===w&&0===k)return[];c=Math.abs(c),p=Math.abs(p);var E=Math.pow(w,2)/Math.pow(c,2)+Math.pow(k,2)/Math.pow(p,2);E>1&&(c*=Math.sqrt(E),p*=Math.sqrt(E));var C=function(e,n,r,a,i,l,s,u,c,p,f,d){var h=Math.pow(i,2),g=Math.pow(l,2),y=Math.pow(f,2),v=Math.pow(d,2),m=h*g-h*v-g*y;m<0&&(m=0),m/=h*v+g*y;var x=(m=Math.sqrt(m)*(s===u?-1:1))*i/l*d,b=m*-l/i*f,w=p*x-c*b+(e+r)/2,k=c*x+p*b+(n+a)/2,E=(f-x)/i,C=(d-b)/l,_=(-f-x)/i,T=(-d-b)/l,M=o(1,0,E,C),S=o(E,C,_,T);return 0===u&&S>0&&(S-=t),1===u&&S<0&&(S+=t),[w,k,M,S]}(i,l,s,u,c,p,g,v,x,b,w,k),_=e(C,4),T=_[0],M=_[1],S=_[2],A=_[3],R=Math.max(Math.ceil(Math.abs(A)/(t/4)),1);A/=R;for(var L=0;Le-1&&(a-=e),r[a]=o}t.push(r)}return t})(e.length).forEach(function(r){var o=0,a=0;r.forEach(function(n){o+=function(e,t){var n=e[0],r=e[2],o=e[4],a=e[6],i=e[1],l=e[3],s=e[5],u=e[7],c=t[0],p=t[2],f=t[4],d=t[6],h=t[1],g=t[3],y=t[5],v=t[7];return Math.sqrt(Math.pow(c-n,2)+Math.pow(h-i,2))+Math.sqrt(Math.pow(p-r,2)+Math.pow(g-l,2))+Math.sqrt(Math.pow(f-o,2)+Math.pow(y-s,2))+Math.sqrt(Math.pow(d-a,2)+Math.pow(v-u,2))}(e[n],t[a++])}),n.push({index:r,distance:o})}),n.sort(function(e,t){return e.distance-t.distance});var r=[];return n[0].index.forEach(function(t){r.push(e[t])}),r}function p(e,t){var n=[];(function(e){for(var t=[],n=0;n2&&(t.push([n].concat(r.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(r.length==i[o])return r.unshift(n),t.push(r);if(r.lengtho-1&&(r-=o)},f._splitCurves=function(e,t){for(var n=0,r=0;n=e.length-1&&(r=0)}},f._upShapes=function(e,t){for(var n=function(t){var n=[];e[e.length-1].forEach(function(e){n.push(e.slice(0))}),e.push(n)},r=0;rr?f._subShapes(o,a,n-r):nr?n=p)return i(c=n,1),a(c),void cancelAnimationFrame(u);var l=s(t/p);c=f._lerp(r[0],r[1],l),i(c,l),u=requestAnimationFrame(e)}()},f})},function(e,t,n){"use strict";!function(){for(var e=0,t=["webkit","moz"],n=0;n"+(e.currentTime||n(0))+""+(e.duration||n(0))+"",{},"xgplayer-time");e.controls.appendChild(o);var a=function(){o.innerHTML=""+n(e.currentTime||0)+""+n(e.duration)};e.on("durationchange",a),e.on("timeupdate",a),e.once("destroy",function(){e.off("durationchange",a),e.off("timeupdate",a),o=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("textTrack",function(){var e=this,t=r.default.util,n=(r.default.sniffer,t.createDom("xg-textTrack","",{tabindex:7},"xgplayer-textTrack")),o=e.controls,a=e.config.textTrack;a&&a instanceof Array&&a.length>1&&(t.addClass(e.root,"xgplayer-is-textTrack"),e.on("canplay",function(){var t=["
    "];t.push("
  • 关闭
  • "),a.forEach(function(e){t.push("
  • "+e.label+"
  • ")});var r=e.config.lang&&"zh-cn"===e.config.lang?"字幕":"Caption";t.push('

'+r+"

");var i=o.querySelector(".xgplayer-textTrack");i?i.innerHTML=t.join(""):(n.innerHTML=t.join(""),o.appendChild(n))})),["touchstart","click"].forEach(function(r){n.addEventListener(r,function(r){r.preventDefault(),r.stopPropagation();var o=r.target||r.srcElement;if(o&&"li"===o.tagName.toLocaleLowerCase()){Array.prototype.forEach.call(o.parentNode.childNodes,function(e){t.removeClass(e,"textTrack")}),t.addClass(o,"textTrack");var i=e.root.getElementsByTagName("Track");"关闭"===o.innerHTML?i[0].track.mode="hidden":(i[0].track.mode="showing",a.some(function(e){if(e.label===o.innerHTML)return i[0].src=e.src,e.kind&&(i[0].kind=e.kind),i[0].label=e.label,e.srclang&&(i[0].srclang=e.srclang),!0}),e.emit("textTrackChange",o.innerHTML))}else!o||"p"!==o.tagName.toLocaleLowerCase()&&"em"!==o.tagName.toLocaleLowerCase()||(t.addClass(n,"xgplayer-textTrack-active"),n.focus())},!1)}),n.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.removeClass(n,"xgplayer-textTrack-active")}),e.once("destroy",function(){n=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("replay",function(){var e=this,t=r.default.util,n=t.createDom("xg-replay",'\n \n \n \n 重播\n ',{},"xgplayer-replay"),o=e.root,a=n.querySelector(".xgplayer-replay-svg");o.appendChild(n),e.on("ended",function(){n.querySelector(".xgplayer-replay-txt").textContent=e.lang.REPLAY,e.config.loop||t.addClass(o,"replay")}),a.addEventListener("click",function(n){n.preventDefault(),t.removeClass(o,"replay"),e.replay()}),e.once("destroy",function(){a=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("progress",function(){var e=this,t=r.default.util,n=t.createDom("xg-progress",'',{tabindex:1},"xgplayer-progress"),o=void 0;e.controls.appendChild(n);var a=n.querySelector(".xgplayer-progress-played"),i=n.querySelector(".xgplayer-progress-cache"),l=n.querySelector(".xgplayer-progress-point"),s=n.querySelector(".xgplayer-progress-thumbnail"),u=0,c=0,p=0,f=0,d=0,h=0,g=[];e.config.thumbnail&&(u=e.config.thumbnail.pic_num,c=e.config.thumbnail.width,p=e.config.thumbnail.height,f=e.config.thumbnail.col,d=e.config.thumbnail.row,g=e.config.thumbnail.urls,s.style.width=c+"px",s.style.height=p+"px"),["touchstart","mousedown"].forEach(function(r){n.addEventListener(r,function(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),r._target===l||e.ended)return!1;n.focus(),o=n.getBoundingClientRect().width;var i=a.getBoundingClientRect().left,s=!1,u=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),s=!0;var r=n.clientX-i,l=r/o*e.duration;a.style.width=100*r/o+"%",e.currentTime=Number(l).toFixed(1)},c=function r(l){if(l.preventDefault(),l.stopPropagation(),t.event(l),window.removeEventListener("mousemove",u),window.removeEventListener("touchmove",u),window.removeEventListener("mouseup",r),window.removeEventListener("touchend",r),n.blur(),!s){var c=l.clientX-i,p=c/o*e.duration;a.style.width=100*c/o+"%",e.currentTime=Number(p).toFixed(1)}s=!1};return window.addEventListener("mousemove",u),window.addEventListener("touchmove",u),window.addEventListener("mouseup",c),window.addEventListener("touchend",c),!1})}),n.addEventListener("mouseenter",function(r){if(e.ended)return!1;var o=n.getBoundingClientRect().left,a=n.getBoundingClientRect().width,i=function(n){var r=(n.clientX-o)/a*e.duration;l.textContent=t.format(r);var i=l.getBoundingClientRect().width;if(e.config.thumbnail){h=e.duration/u;var y=Math.floor(r/h);s.style.backgroundImage="url("+g[Math.ceil((y+1)/(f*d))-1]+")";var v=y+1-f*d*(Math.ceil((y+1)/(f*d))-1),m=Math.ceil(v/d)-1,x=v-m*d-1;s.style["background-position"]="-"+x*c+"px -"+m*p+"px";var b=n.clientX-o-c/2;b=(b=b>0?b:0)0?w:0)>a-i?a-i:w,l.style.left=w+"px"}l.style.display="block"},y=function(e){i(e)};n.addEventListener("mousemove",y,!1),n.addEventListener("mouseleave",function e(t){n.removeEventListener("mousemove",y,!1),n.removeEventListener("mouseleave",e,!1),i(t),l.style.display="none",s.style.display="none"},!1),i(r)},!1),e.on("timeupdate",function(){!o&&n&&(o=n.getBoundingClientRect().width),a.style.width=100*e.currentTime/e.duration+"%"}),["cacheupdate","ended","timeupdate"].forEach(function(t){e.on(t,function(){var t=e.buffered;if(t&&t.length>0){var n=t.end(t.length-1);i.style.width=n/e.duration*100+"%"}})}),e.once("destroy",function(){n=null,a=null,l=null,s=null,i=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("poster",function(){var e=r.default.util.createDom("xg-poster","",{},"xgplayer-poster"),t=this.root;this.config.poster&&(e.style.backgroundImage="url("+this.config.poster+")",t.appendChild(e)),this.on("play",function(){e.style.display="none"}),this.once("destroy",function(){e=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("playbackRate",function(){var e=this,t=r.default.util,n=0,o=[];if(!e.config.playbackRate)return!1;e.config.playbackRate.sort(function(e,t){return e-t}),e.config.playbackRate.forEach(function(e,t){1!==e&&"1"!==e||(n=t),o.push(e+"x")});var a=e.config.lang&&"zh-cn"===e.config.lang?"倍速":"Speed",i=t.createDom("xg-playback",'

1x

',{},"xgplayer-playback"),l=e.controls,s=t.createDom("xg-tips",a,{},"xgplayer-tips");i.appendChild(s),l.appendChild(i),["touchstart","click"].forEach(function(t){i.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation();var r=t.target||t.srcElement;(r&&"p"===r.tagName.toLocaleLowerCase()||"span"===r.tagName.toLocaleLowerCase())&&(n=n+1===o.length?0:n+1,i.querySelector("p").innerHTML=""+o[n]+"",e.video.playbackRate=1*o[n].replace(/x$/g,""))},!1)}),i.addEventListener("mouseenter",function(t){t.preventDefault(),t.stopPropagation(),s.style.left="50%";var n=s.getBoundingClientRect(),r=e.root.getBoundingClientRect();n.right>r.right&&(s.style.left=-n.right+r.right+16+"px")}),e.once("destroy",function(){i=null})})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("play",function(){var e=this,t=e.controls,n=r.default.util,a=e.config.iconScale||.0320625,i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=n.createDom("xg-play",'\n \n '),u=e.config.lang&&"zh-cn"===e.config.lang?"播放":"Play",c=e.config.lang&&"zh-cn"===e.config.lang?"暂停":"Pause",p=n.createDom("xg-tips",u,{},"xgplayer-tips"),f=s.querySelector("path");s.appendChild(p);var d=new o.default({progress:function(e,t){f.setAttribute("d",d.toSVGString(e))},from:l,to:i});s.className="xgplayer-play",t.appendChild(s),["click","touchstart"].forEach(function(t){s.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.ended||(e.paused?e.play():e.pause())},!1)}),e.on("play",function(){p.textContent=c,d.to!==l&&d.reset(l,i)}),e.on("pause",function(){p.textContent=u,d.to!==i&&d.reset(i,l)}),e.once("destroy",function(){s=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("pc",function(){var e=this,t=r.default.util,n=e.controls,o=e.root,a=0,i=void 0,l="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",s="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",u=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),c=t.createDom("xg-enter",'',{},"xgplayer-enter"),p=c.querySelector(".xgplayer-enter-logo");o.appendChild(u),o.appendChild(c);var f=u.querySelector("path"),d=new Image;d.onload=function(){c.querySelector(".xgplayer-enter-tips").style.display="block"},e.config.enterLogo?(d.src=e.config.enterLogo,p.style.backgroundImage='url("'+e.config.enterLogo+'")'):d.src=t.getBgImage(p),["click","touchstart"].forEach(function(n){u.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),e.config.url&&(t.hasClass(o,"xgplayer-nostart")?(t.removeClass(o,"xgplayer-nostart"),t.addClass(o,"xgplayer-is-enter"),o.querySelector("video")||e.start(),e.on("canplay",function(){t.removeClass(o,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(o,"xgplayer-is-enter")}),e.play(),setTimeout(function(){e.play()},10)):e.paused&&(t.removeClass(o,"xgplayer-nostart xgplayer-isloading"),setTimeout(function(){e.play()},10)))})}),u.addEventListener("animationend",function(e){e.preventDefault(),t.removeClass(u,"xgplayer-start-interact"),u.style.display="none"}),e.on("play",function(){f.setAttribute("d",l),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.on("pause",function(){f.setAttribute("d",s),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.video.addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),document.activeElement===e.video?(a++,i&&clearTimeout(i),1===a?i=setTimeout(function(){if(t.hasClass(e.root,"xgplayer-nostart"))return!1;e.ended||(e.paused?e.play():e.pause()),a=0},200):a=0):e.video.focus()},!1),e.video.addEventListener("dblclick",function(t){if(t.preventDefault(),t.stopPropagation(),document.activeElement===e.video){var r=n.querySelector(".xgplayer-fullscreen");if(r){var o=void 0;document.createEvent?(o=document.createEvent("Event")).initEvent("click",!0,!0):o=new Event("click"),r.dispatchEvent(o)}}else e.video.focus()},!1),o.addEventListener("mouseenter",function(t){e.emit("focus",e)},!1),o.addEventListener("mouseleave",function(t){e.emit("blur",e)},!1),n.addEventListener("mouseenter",function(t){e.userTimer&&clearTimeout(e.userTimer)},!1),n.addEventListener("mouseleave",function(t){e.emit("focus",e)},!1)})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("mobile",function(){var e=this,t=r.default.util,n=e.root;e.config.autoplay=!1;var a=function(e){var t=r.default.util;return e.some(function(e){return"Function"===t.typeOf(e)?e.call(navigator.userAgent):"RegExp"===t.typeOf(e)?e.test(navigator.userAgent):"String"===t.typeOf(e)&&navigator.userAgent.indexOf(e)>-1})}(e.config.whitelist);e.mobilePass=a;var i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),u=t.createDom("xg-enter",'',{},"xgplayer-enter"),c=u.querySelector(".xgplayer-enter-logo");n.appendChild(s),n.appendChild(u);var p=s.querySelector("path"),f=new Image,d=new o.default({from:l,to:i,progress:function(e,t){p.setAttribute("d",d.toSVGString(e))}});u.querySelector(".xgplayer-enter-tips").style.display="block",e.start(),a?(e.config.enterLogo?(f.src=e.config.enterLogo,c.style.backgroundImage='url("'+e.config.enterLogo+'")'):f.src=t.getBgImage(c),e.video.addEventListener("touchstart",function(t){t.preventDefault(),e.emit("focus")},!1),s.addEventListener("touchend",function(r){r.preventDefault(),t.hasClass(n,"xgplayer-nostart")?(t.removeClass(n,"xgplayer-nostart"),t.addClass(n,"xgplayer-is-enter"),e.on("canplay",function(){t.removeClass(n,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(n,"xgplayer-is-enter")}),e.play()):e.paused?e.play():e.pause()}),e.on("play",function(){d.reset(l,i)}),e.on("pause",function(){d.reset(i,l)})):(t.addClass(n,"xgplayer-mobile-npassed"),e.once("ready",function(){e.video.controls=e.config.controls,e.video.controlsList=e.config.controlsList.join(" "),e.config.poster&&(e.video.poster=e.config.poster)})),e.config.debug&&function(e){var t={};Object.assign(t,{host:"127.0.0.1",port:9090},e);var n=document.createElement("script"),r=document.createElement("h4");r.style.cssText="position:fixed;bottom:0;padding:10px;width:100%;background-color:#fff;text-align:center",r.textContent="weinre --boundHost "+t.host+" --httpPort "+t.port+"\r\n 启动服务后,刷新页面",n.anonymous=!0,n.async=!0,n.src="http://"+t.host+":"+t.port+"/target/target-script-min.js#anonymous",n.onload=function(){r.parentNode.removeChild(r)},document.body.appendChild(n),document.body.appendChild(r)}(e.config.debug)})},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;ni.length){for(var c=function(e){i[e]={id:e,queue:[],step:t.channels[e].step,surplus:t.channels[e].surplus},t.channels[e].queue.forEach(function(t){return i[e].queue.push(t)})},p=0;pn.length)return{result:!1,message:"exceed channels.length, occupy="+o+",channelsSize="+n.length};for(var a=!0,i=void 0,l=-1,s=0,u=n.length;s-1&&(r.queue.splice(i,1),0===i&&(r.step=9999,r.surplus=0))}}},{key:"update",value:function(){var e=this.channels,t=this.width;e.forEach(function(e){var n=e.queue[0];n?e.surplus=t-n.left-n.width:(e.step=9999,e.surplus=0)})}},{key:"reset",value:function(){var e=this.player.root,t=this;setTimeout(function(){var n=e.querySelector(".xgplayer-bullet"),r=n.getBoundingClientRect();t.width=r.width,t.height=r.height,t.container=n;for(var o=/mobile/gi.test(navigator.userAgent)?10:12,a=Math.floor(t.height/o),i=[],l=0;l0?e.map(function(e){return{id:e.danmaku_id,txt:e.text.slice(0,40),duration:1*e.duration,color:e.text_color.replace("0x","#"),scale:1*e.text_scale,start:1*e.offset_time}}):[]}},n),t.on("dataIncoming",this.dataHandle.bind(this)),t.on("seeked",this.seekHandle.bind(this)),t.on("bullet_remove",this.updateQueue.bind(this)),t.on("ended",this.stop.bind(this)),t.on("pause",this.pause.bind(this)),t.on("play",this.play.bind(this))}return r(e,[{key:"updateQueue",value:function(e){var t=this;t.queue.some(function(n,r){if(n.id===e.bullet.id)return t.queue.splice(r,1),!0})}},{key:"init",value:function(){var e=this;if(e.data)return e.player.paused?void(e.status="paused"):e.player.ended?void(e.status="ended"):(e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),void e.player.emit("dataIncoming"));fetch(e.options.url,{method:e.options.method,headers:{Accept:"application/json"}}).then(function(t){t.ok&&t.json().then(function(t){var n=e.options.dataMap.call(null,t.data);if(n.length){e.data=n;var r=document.createElement("span");r.style.padding=e.options.padding+"||'0px'",r.style.position="absolute",r.style.left="-99999px",document.body.appendChild(r);var o=void 0;if(e.data.forEach(function(e){r.textContent=e.txt,r.style.fontSize=20*e.scale+"px",o=r.getBoundingClientRect(),e.width=o.width,e.height=o.height}),e.data.sort(function(e,t){return e.start-t.start}),document.body.removeChild(r),e.player.paused)return void(e.status="paused");if(e.player.ended)return void(e.status="ended");e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),e.player.emit("dataIncoming")}})}).catch(function(e){console.log("Fetch错误:"+e)})}},{key:"start",value:function(){this.status="playing",this.channel.reset(),this.init()}},{key:"stop",value:function(){this.status="closed",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer),this.queue.length=0,this.container.innerHTML=""}},{key:"play",value:function(){var e=this,t=o.default.util;"idle"===e.status||"ended"===e.status?t.hasClass(e.container,"xgplayer-has-bullet")&&e.start():"paused"===e.status&&t.hasClass(e.container,"xgplayer-has-bullet")&&(e.status="playing",e.dataHandle(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3))}},{key:"pause",value:function(){"playing"===this.status?(this.status="paused",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer)):"ended"===this.status&&this.stop()}},{key:"dataHandle",value:function(){var e=(0,a.default)("cancel");if(e(this.timer),this.queue.length){this.queue.forEach(function(e){"waiting"!==e.status&&"start"!==e.status||(e.status="start",e.move())});var t=(0,a.default)("request");this.timer=t(this.dataHandle.bind(this))}else e(this.timer)}},{key:"readData",value:function(){var e=this,t=this.player,n=this.formatTime(t.currentTime),r=void 0,o=e.interval,a=e.channel,i=e.container,l=e.data.filter(function(e){return e.start<=n&&n<=e.start+o});l.length>0&&l.forEach(function(n){r=new c(t,i,n),a.addBullet(r).result&&(e.queue.push(r),r.reset(),r.attach())})}},{key:"seekHandle",value:function(){o.default.util;this.stop(),this.player.paused?this.status="idle":(this.status="playing",this.channel.resetWithCb(),this.init())}},{key:"formatTime",value:function(e){var t=Math.floor(e);return 1e3*t+(e-t)}}]),e}(),f=function(){function e(t,n){s(this,e);var r=this;this.player=t,this.el_=this.createEl(),this.onceFlag=!1;["click","touchstart"].forEach(function(e){r.el_.addEventListener(e,function(e){e.preventDefault(),e.stopPropagation(),r.onClick()},!1)}),this.main=new p(t,n),"on"===n.switch&&this.player.once("play",function(){r.onChange(!0)})}return r(e,[{key:"createEl",value:function(){return o.default.util.createDom("xg-bullet-btn",'',{},"xgplayer-bullet-btn "+("on"===this.player.config.bullet.switch?"xgplayer-bullet-btn-active":""))}},{key:"onClick",value:function(){var e=this,t=o.default.util;t.toggleClass(e.el_,"xgplayer-bullet-btn-active");var n=!!t.hasClass(e.el_,"xgplayer-bullet-btn-active");function r(){e.onceFlag=!1,e.main.channel.resetWithCb(e.onChange.bind(e))}n?e.player.paused||e.player.ended?this.onceFlag||(this.onceFlag=!0,this.player.once("play",r)):r():(this.player.off("play",r),this.onChange(n))}},{key:"onChange",value:function(e){var t=o.default.util,n=this.player.root.querySelector(".xgplayer-bullet");e?(t.addClass(n,"xgplayer-has-bullet"),this.main.start()):(t.removeClass(n,"xgplayer-has-bullet"),this.main.stop())}}]),e}();o.default.install("makeBullet",function(){var e=this,t=o.default.util;if(e.config.bullet){var n=t.createDom("xg-bullet","",{},"xgplayer-bullet");e.root.appendChild(n);var r=new f(e,e.config.bullet);["touchstart","click"].forEach(function(t){n.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.paused?e.play():e.pause()},!1)}),e.controls.appendChild(r.el_)}})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}; /** * request-frame - requestAnimationFrame & cancelAnimationFrame polyfill for optimal cross-browser development. * @version v1.5.3 diff --git a/packages/xgplayer/dist/index.js b/packages/xgplayer/dist/index.js index 4e4b70599..9279eac3d 100644 --- a/packages/xgplayer/dist/index.js +++ b/packages/xgplayer/dist/index.js @@ -1,4 +1,4 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xgplayer=t():e.xgplayer=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.config.url,n=this.root,r=this;"String"===a.default.typeOf(t)?this.video.src=t:t.forEach(function(t){e.video.appendChild(a.default.createDom("source","",{src:""+t.src,type:""+(t.type||"")}))}),n.insertBefore(this.video,n.firstChild),r.userTimer=setTimeout(function(){r.emit("blur")},r.config.inactive),setTimeout(function(){e.emit("complete")},1)}},{key:"reload",value:function(){this.video.load(),this.once("loadeddata",function(){this.play()})}},{key:"destroy",value:function(){var e=this,t=this.root.parentNode;this.paused?(this.emit("destroy"),t.removeChild(this.root),t.appendChild(this.rootBackup)):(this.pause(),this.once("pause",function(){e.emit("destroy"),t.removeChild(e.root),t.appendChild(e.rootBackup)})),setTimeout(function(){for(var e in this)"config"!==e&&delete this[e]},200)}},{key:"replay",value:function(){var e=this._replay;a.default.removeClass(this.root,"xgplayer-ended"),e&&e instanceof Function?e():(this.currentTime=0,this.play())}},{key:"onFocus",value:function(){var e=this;a.default.removeClass(this.root,"xgplayer-inactive"),e.userTimer&&clearTimeout(e.userTimer),e.userTimer=setTimeout(function(){e.emit("blur")},e.config.inactive)}},{key:"onBlur",value:function(){this.paused||this.ended||a.default.addClass(this.root,"xgplayer-inactive")}},{key:"onPlay",value:function(){a.default.addClass(this.root,"xgplayer-playing"),a.default.removeClass(this.root,"xgplayer-pause")}},{key:"onPause",value:function(){a.default.addClass(this.root,"xgplayer-pause"),this.userTimer&&clearTimeout(this.userTimer),this.emit("focus")}},{key:"onEnded",value:function(){a.default.addClass(this.root,"xgplayer-ended"),a.default.removeClass(this.root,"xgplayer-playing")}},{key:"onSeeking",value:function(){}},{key:"onSeeked",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading")}},{key:"onWaiting",value:function(){var e=this;e.waitTimer&&clearTimeout(e.waitTimer),e.waitTimer=setTimeout(function(){a.default.addClass(e.root,"xgplayer-isloading")},500)}},{key:"onPlaying",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading xgplayer-nostart xgplayer-pause xgplayer-ended xgplayer-is-error xgplayer-replay"),a.default.addClass(this.root,"xgplayer-playing")}}],[{key:"install",value:function(e,n){t.plugins||(t.plugins={}),t.plugins[e]=n}}]),t}();p.util=a.default,p.sniffer=i.default,p.Errors=l.default,t.default=p,e.exports=t.default},function(e,t,n){"use strict";var r=n(17)();e.exports=function(e){return e!==r&&null!==e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.from=t.from,this.to=t.to,this.easing=t.easing||function(e){return e*e},this.duration=t.duration||150,this.curPath="",this.progress=t.progress,this.state=0}return r(e,[{key:"animate",value:function(){var e=this,t=new Date,n=e.duration,r=null,o=e.path2shapes(e.from),a=e.path2shapes(e.to),i=e._preprocessing(o,a);e.state=1;!function o(){var l=new Date-t;if(l>=n||2===e.state)return r=a,e.progress(r,1),window.cancelAnimationFrame(e.tickId),void(e.state=0);var s=e.easing(l/n);r=e._lerp(i[0],i[1],s),e.progress(r,s),e.tickId=window.requestAnimationFrame(o)}()}},{key:"toSVGString",value:function(e){return e.map(function(e){return e.forEach(function(e,t){t?e.splice(0,2,"C"):(e.splice(2,0,"C"),e.unshift("M"))}),e.map(function(e){return e.join(" ")}).join("")}).join("")}},{key:"start",value:function(){self.animate()}},{key:"stop",value:function(){0!==this.state&&(this.state=2),window.cancelAnimationFrame(self.tickId),this.state=0}},{key:"reverse",value:function(){0!==this.state&&this.stop();var e=this.from;this.from=this.to,this.to=e,this.animate()}},{key:"reset",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.from;0!==this.state&&this.stop(),this.from=t,this.to=e,this.animate()}}]),e}();for(var i in o.default)o.default[i]instanceof Function&&!a.prototype[i]&&(a.prototype[i]=o.default[i]);t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={createDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=document.createElement(e);return o.className=r,o.innerHTML=t,Object.keys(n).forEach(function(t){var r=t,a=n[t];"video"===e||"audio"===e?a&&o.setAttribute(r,a):o.setAttribute(r,a)}),o},hasClass:function(e,t){return e.classList?Array.prototype.some.call(e.classList,function(e){return e===t}):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:function(e,t){e.classList?t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(t){t&&e.classList.add(t)}):r.hasClass(e,t)||(e.className+=" "+t)},removeClass:function(e,t){e.classList?t.split(/\s+/g).forEach(function(t){e.classList.remove(t)}):r.hasClass(e,t)&&t.split(/\s+/g).forEach(function(t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")})},toggleClass:function(e,t){t.split(/\s+/g).forEach(function(t){r.hasClass(e,t)?r.removeClass(e,t):r.addClass(e,t)})},findDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=arguments[1];return e.querySelector(t)},padStart:function(e,t,n){for(var r=String(n),o=t>>0,a=Math.ceil(o/r.length),i=[],l=String(e);a--;)i.push(r);return i.join("").substring(0,o-l.length)+l},format:function(e){if(window.isNaN(e))return"";var t=r.padStart(Math.floor(e/3600),2,0),n=r.padStart(Math.floor((e-3600*t)/60),2,0),o=r.padStart(Math.floor(e-3600*t-60*n),2,0);return("00"===t?[n,o]:[t,n,o]).join(":")},event:function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},typeOf:function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},deepCopy:function(e,t){if("Object"===r.typeOf(t)&&"Object"===r.typeOf(e))return Object.keys(t).forEach(function(n){"Object"!==r.typeOf(t[n])||t[n]instanceof Node?e[n]=t[n]:e[n]?r.deepCopy(e[n],t[n]):e[n]=t[n]}),e},getBgImage:function(e){var t=document.createElement("a"),n=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;return t.href=n.replace(/url\("|"\)/g,""),t.href},copyDom:function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return Array.prototype.forEach.call(e.attributes,function(e){t.setAttribute(e.name,e.value)}),t}return""}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5);var o={network:{code:1,msg:"视频下载错误",remark:"只要视频下载错误就使用此类型,无论是video本身的超时还是xhr的分段请求超时或者资源不存在"},mse:{code:2,msg:"流追加错误",remark:"追加流的时候如果类型不对、无法被正确解码则会触发此类错误"},parse:{code:3,msg:"解析错误",remark:"mp4、hls、flv我们都是使用js进行格式解析,如果解析失败则会触发此类错误"},format:{code:4,msg:"格式错误",remark:"如果浏览器不支持的格式导致播放错误"},decoder:{code:5,msg:"解码错误",remark:"浏览器解码异常会抛出此类型错误"},runtime:{code:6,msg:"语法错误",remark:"播放器语法错误"},timeout:{code:7,msg:"播放超时",remark:"播放过程中无法正常请求下一个分段导致播放中断"},other:{code:8,msg:"其他错误",remark:"不可知的错误或被忽略的错误类型"}};t.default=function e(t,n,a,i,l,s,u,c){var p=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{line:"",handle:"",msg:"",version:""};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var f={};return f.playerVersion=r.version,f.errorType=t,f.domain=document.domain,f.duration=a,f.currentTime=n,f.networkState=i,f.readyState=l,f.currentSrc=u,f.src=s,f.ended=c,f.errd=p,f.ex=(o[t]||{}).msg,f},e.exports=t.default},function(e){e.exports={name:"xgplayer",version:"1.0.7",description:"video player",main:"./dist/index.js",scripts:{prepare:"npm run build",build:"webpack --progress --display-chunks -p",watch:"webpack --progress --display-chunks -p --watch"},keywords:["video","player"],babel:{presets:["es2015"],plugins:["add-module-exports","babel-plugin-bulk-import"]},repository:{type:"git",url:"git+https://github.com/bytedance/xgplayer.git"},author:"yinguohui@bytedance.com",license:"MIT",dependencies:{"babel-plugin-add-module-exports":"^0.2.1",deepmerge:"^1.5.0","event-emitter":"^0.3.5",pasition:"^1.0.1","request-frame":"^1.5.3"},browserslist:["> 5%","IE 9","iOS 7","Firefox > 20"],devDependencies:{"babel-loader":"^7.1.4","babel-plugin-bulk-import":"^1.0.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-preset-es2015":"^6.24.1","core-js":"^2.5.4","css-loader":"^0.28.11","json-loader":"^0.5.7","node-sass":"^4.8.3","postcss-cssnext":"^3.1.0","postcss-loader":"^2.1.5","sass-loader":"^6.0.7","style-loader":"^0.20.3",sugarss:"^1.0.1",webpack:"^4.8.1","webpack-cli":"^2.1.3",zlib:"^1.0.5"}}},function(e,t,n){e.exports=n(7)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=w(n(0)),o=w(n(26)),a=w(n(29)),i=w(n(30)),l=w(n(31)),s=w(n(32)),u=w(n(33)),c=w(n(34)),p=w(n(35)),f=w(n(36)),d=w(n(37)),h=w(n(38)),g=w(n(41)),y=w(n(42)),v=w(n(43)),m=w(n(44)),x=w(n(45)),b=w(n(46));function w(e){return e&&e.__esModule?e:{default:e}}n(47);var k={};function E(e,t,n){var r=e;t.map(function(e,o){r[e]=o==t.length-1?n:r[e]||{},r=r[e]})}E(k,["control","definition"],b.default),E(k,["control","error"],x.default),E(k,["control","flex"],m.default),E(k,["control","fullscreen"],v.default),E(k,["control","i18n"],y.default),E(k,["control","loading"],g.default),E(k,["control","makeBullet"],h.default),E(k,["control","mobile"],d.default),E(k,["control","pc"],f.default),E(k,["control","play"],p.default),E(k,["control","playbackRate"],c.default),E(k,["control","poster"],u.default),E(k,["control","progress"],s.default),E(k,["control","replay"],l.default),E(k,["control","textTrack"],i.default),E(k,["control","time"],a.default),E(k,["control","volume"],o.default),t.default=r.default,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n",!0}),r.crossorigin="anonymous"),t.textTrackStyle){var s=document.createElement("style");document.head.appendChild(s);var u="";for(var c in t.textTrackStyle)u+=c+": "+t.textTrackStyle[c]+";";var p=t.id?"#"+t.id:t.el.id?"#"+t.el.id:"."+t.el.className;s.sheet.addRule(p+" video::cue",u),s.sheet.insertRule(p+" video::cue { "+u+" }",0)}this.video=a.default.createDom(r.mediaType,l,r,""),this.ev=["play","playing","pause","ended","error","seeking","seeked","timeupdate","waiting","canplay","canplaythrough","durationchange","volumechange","loadeddata"].map(function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e,"on"+e.charAt(0).toUpperCase()+e.slice(1))}),(0,o.default)(this),this.ev.forEach(function(e){var t=n,r=Object.keys(e)[0];t.video.addEventListener(r,function(){"play"===r&&(t.hasStart=!0),"error"===r?t.video.error&&t.emit(r,new i.default("other",t.currentTime,t.duration,t.networkState,t.readyState,t.currentSrc,t.src,t.ended,{line:41,msg:t.error,handle:"Constructor"})):t.emit(r,t)},!1)})}return r(e,[{key:"play",value:function(){this.video.play()}},{key:"pause",value:function(){this.video.pause()}},{key:"canPlayType",value:function(){this.video.canPlayType()}},{key:"getBufferedRange",value:function(){var e=[0,0],t=this.video,n=t.buffered,r=t.currentTime;if(n)for(var o=0,a=n.length;o-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={get device(){var e=r.os;return e.isPc?"pc":e.isTablet?"tablet":"mobile"},get browser(){var e=navigator.userAgent.toLowerCase(),t={ie:/rv:([\d.]+)\) like gecko/,firfox:/firefox\/([\d.]+)/,chrome:/chrome\/([\d.]+)/,opera:/opera.([\d.]+)/,safari:/version\/([\d.]+).*safari/};return[].concat(Object.keys(t).filter(function(n){return t[n].test(e)}))[0]},get os(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),n=/(?:SymbianOS)/.test(e)||t,r=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e),a=/(?:iPad|PlayBook)/.test(e)||r&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),i=/(?:iPhone)/.test(e)&&!a;return{isTablet:a,isPhone:i,isAndroid:r,isPc:!i&&!r&&!n,isSymbian:n,isWindowsPhone:t,isFireFox:o}}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("volume",function(){var e=this,t=r.default.util,n=e.config.volume,a={muted:"M920.4 439.808l-108.544-109.056-72.704 72.704 109.568 108.544-109.056 108.544 72.704 72.704 108.032-109.568 108.544 109.056 72.704-72.704-109.568-108.032 109.056-108.544-72.704-72.704-108.032 109.568z",small:"M795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z",large:"M940.632 837.632l-72.192-72.192c65.114-64.745 105.412-154.386 105.412-253.44s-40.299-188.695-105.396-253.424l-0.016-0.016 72.192-72.192c83.639 83.197 135.401 198.37 135.401 325.632s-51.762 242.434-135.381 325.612l-0.020 0.020zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z"},i=function(e){return 0===e?"muted":e<.5?"small":"large"},l=a[i(n)],s=a[i(n)],u=t.createDom("xg-volume",'\n \n \n \n \n \n \n \n \n \n ',{},"xgplayer-volume"),c=e.controls;c.appendChild(u);var p=void 0,f=u.querySelector(".xgplayer-slider"),d=u.querySelector(".xgplayer-bar"),h=u.querySelector(".xgplayer-drag"),g=u.querySelector(".xgplayer-icon");h.style.height=100*e.config.volume+"%";var y=c.querySelectorAll("path")[1],v=new o.default({progress:function(e,t){var n=v.toSVGString(e);y.setAttribute("d",n),l=n},from:l,to:a.large}),m=null;f.volume=e.config.volume,["touchstart","mousedown"].forEach(function(n){d.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),f.focus(),t.event(n),p=d.getBoundingClientRect().height,n.clientX;var r=n.clientY,o=h.getBoundingClientRect().height,a=!1,i=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),a=!0;var i=o-n.clientY+r,l=i/p;h.style.height=i+"px",e.volume=Math.max(Math.min(l,1),.01)},l=function n(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),window.removeEventListener("mousemove",i),window.removeEventListener("touchmove",i),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),m||(m=d.getBoundingClientRect()),!a){var o=m.height-(r.clientY-m.top),l=o/m.height;h.style.height=o+"px",l<=0&&(e.volume>0?h.volume=e.video.volume:l=h.volume),e.volume=Math.max(Math.min(l,1),.01)}f.volume=e.volume,a=!1};return window.addEventListener("mousemove",i),window.addEventListener("touchmove",i),window.addEventListener("mouseup",l),window.addEventListener("touchend",l),!1})}),["touchstart","mousedown"].forEach(function(n){g.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),t.hasClass(f,"xgplayer-none")?(t.removeClass(f,"xgplayer-none"),f.focus()):0===e.volume?e.volume=f.volume:e.volume=0})}),f.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.addClass(f,"xgplayer-none")});var x=null;e.on("volumechange",function(){x&&clearTimeout(x),x=setTimeout(function(){v.reset(a[i(e.volume)],l),l=a[i[e.volume]],p||(p=d.getBoundingClientRect().height||76),h.style.height=e.volume*p+"px"},50)}),e.once("canplay",function(){e.volume=e.config.volume}),e.once("destroy",function(){u=null,h=null})})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(i,l){"object"===a(t)&&void 0!==e?e.exports=l():void 0===(o="function"==typeof(r=l)?r.call(t,n,t,e):r)||(e.exports=o)}(0,function(){var e=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{!r&&l.return&&l.return()}finally{if(o)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),t=2*Math.PI,n=function(e,t,n,r,o,a,i){var l=e.x,s=e.y;return{x:r*(l*=t)-o*(s*=n)+a,y:o*l+r*s+i}},r=function(e,t){var n=4/3*Math.tan(t/4),r=Math.cos(e),o=Math.sin(e),a=Math.cos(e+t),i=Math.sin(e+t);return[{x:r-o*n,y:o+r*n},{x:a+i*n,y:i-a*n},{x:a,y:i}]},o=function(e,t,n,r){var o=e*r-t*n<0?-1:1,a=(e*n+t*r)/(Math.sqrt(e*e+t*t)*Math.sqrt(e*e+t*t));return a>1&&(a=1),a<-1&&(a=-1),o*Math.acos(a)},a=function(a){var i=a.px,l=a.py,s=a.cx,u=a.cy,c=a.rx,p=a.ry,f=a.xAxisRotation,d=void 0===f?0:f,h=a.largeArcFlag,g=void 0===h?0:h,y=a.sweepFlag,v=void 0===y?0:y,m=[];if(0===c||0===p)return[];var x=Math.sin(d*t/360),b=Math.cos(d*t/360),w=b*(i-s)/2+x*(l-u)/2,k=-x*(i-s)/2+b*(l-u)/2;if(0===w&&0===k)return[];c=Math.abs(c),p=Math.abs(p);var E=Math.pow(w,2)/Math.pow(c,2)+Math.pow(k,2)/Math.pow(p,2);E>1&&(c*=Math.sqrt(E),p*=Math.sqrt(E));var C=function(e,n,r,a,i,l,s,u,c,p,f,d){var h=Math.pow(i,2),g=Math.pow(l,2),y=Math.pow(f,2),v=Math.pow(d,2),m=h*g-h*v-g*y;m<0&&(m=0),m/=h*v+g*y;var x=(m=Math.sqrt(m)*(s===u?-1:1))*i/l*d,b=m*-l/i*f,w=p*x-c*b+(e+r)/2,k=c*x+p*b+(n+a)/2,E=(f-x)/i,C=(d-b)/l,_=(-f-x)/i,T=(-d-b)/l,M=o(1,0,E,C),S=o(E,C,_,T);return 0===u&&S>0&&(S-=t),1===u&&S<0&&(S+=t),[w,k,M,S]}(i,l,s,u,c,p,g,v,x,b,w,k),_=e(C,4),T=_[0],M=_[1],S=_[2],A=_[3],R=Math.max(Math.ceil(Math.abs(A)/(t/4)),1);A/=R;for(var L=0;Le-1&&(a-=e),r[a]=o}t.push(r)}return t})(e.length).forEach(function(r){var o=0,a=0;r.forEach(function(n){o+=function(e,t){var n=e[0],r=e[2],o=e[4],a=e[6],i=e[1],l=e[3],s=e[5],u=e[7],c=t[0],p=t[2],f=t[4],d=t[6],h=t[1],g=t[3],y=t[5],v=t[7];return Math.sqrt(Math.pow(c-n,2)+Math.pow(h-i,2))+Math.sqrt(Math.pow(p-r,2)+Math.pow(g-l,2))+Math.sqrt(Math.pow(f-o,2)+Math.pow(y-s,2))+Math.sqrt(Math.pow(d-a,2)+Math.pow(v-u,2))}(e[n],t[a++])}),n.push({index:r,distance:o})}),n.sort(function(e,t){return e.distance-t.distance});var r=[];return n[0].index.forEach(function(t){r.push(e[t])}),r}function p(e,t){var n=[];(function(e){for(var t=[],n=0;n2&&(t.push([n].concat(r.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(r.length==i[o])return r.unshift(n),t.push(r);if(r.lengtho-1&&(r-=o)},f._splitCurves=function(e,t){for(var n=0,r=0;n=e.length-1&&(r=0)}},f._upShapes=function(e,t){for(var n=function(t){var n=[];e[e.length-1].forEach(function(e){n.push(e.slice(0))}),e.push(n)},r=0;rr?f._subShapes(o,a,n-r):nr?n=p)return i(c=n,1),a(c),void cancelAnimationFrame(u);var l=s(t/p);c=f._lerp(r[0],r[1],l),i(c,l),u=requestAnimationFrame(e)}()},f})},function(e,t,n){"use strict";!function(){for(var e=0,t=["webkit","moz"],n=0;n"+(e.currentTime||n(0))+""+(e.duration||n(0))+"",{},"xgplayer-time");e.controls.appendChild(o);var a=function(){o.innerHTML=""+n(e.currentTime||0)+""+n(e.duration)};e.on("durationchange",a),e.on("timeupdate",a),e.once("destroy",function(){e.off("durationchange",a),e.off("timeupdate",a),o=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("textTrack",function(){var e=this,t=r.default.util,n=(r.default.sniffer,t.createDom("xg-textTrack","",{tabindex:7},"xgplayer-textTrack")),o=e.controls,a=e.config.textTrack;a&&a instanceof Array&&a.length>1&&(t.addClass(e.root,"xgplayer-is-textTrack"),e.on("canplay",function(){var t=["
    "];t.push("
  • 关闭
  • "),a.forEach(function(e){t.push("
  • "+e.label+"
  • ")});var r=e.config.lang&&"zh-cn"===e.config.lang?"字幕":"Caption";t.push('

'+r+"

");var i=o.querySelector(".xgplayer-textTrack");i?i.innerHTML=t.join(""):(n.innerHTML=t.join(""),o.appendChild(n))})),["touchstart","click"].forEach(function(r){n.addEventListener(r,function(r){r.preventDefault(),r.stopPropagation();var o=r.target||r.srcElement;if(o&&"li"===o.tagName.toLocaleLowerCase()){Array.prototype.forEach.call(o.parentNode.childNodes,function(e){t.removeClass(e,"textTrack")}),t.addClass(o,"textTrack");var i=e.root.getElementsByTagName("Track");"关闭"===o.innerHTML?i[0].track.mode="hidden":(i[0].track.mode="showing",a.some(function(e){if(e.label===o.innerHTML)return i[0].src=e.src,e.kind&&(i[0].kind=e.kind),i[0].label=e.label,e.srclang&&(i[0].srclang=e.srclang),!0}),e.emit("textTrackChange",o.innerHTML))}else!o||"p"!==o.tagName.toLocaleLowerCase()&&"em"!==o.tagName.toLocaleLowerCase()||(t.addClass(n,"xgplayer-textTrack-active"),n.focus())},!1)}),n.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.removeClass(n,"xgplayer-textTrack-active")}),e.once("destroy",function(){n=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("replay",function(){var e=this,t=r.default.util,n=t.createDom("xg-replay",'\n \n \n \n 重播\n ',{},"xgplayer-replay"),o=e.root,a=n.querySelector(".xgplayer-replay-svg");o.appendChild(n),e.on("ended",function(){n.querySelector(".xgplayer-replay-txt").textContent=e.lang.REPLAY,e.config.loop||t.addClass(o,"replay")}),a.addEventListener("click",function(n){n.preventDefault(),t.removeClass(o,"replay"),e.replay()}),e.once("destroy",function(){a=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("progress",function(){var e=this,t=r.default.util,n=t.createDom("xg-progress",'',{tabindex:1},"xgplayer-progress"),o=void 0;e.controls.appendChild(n);var a=n.querySelector(".xgplayer-progress-played"),i=n.querySelector(".xgplayer-progress-cache"),l=n.querySelector(".xgplayer-progress-point"),s=n.querySelector(".xgplayer-progress-thumbnail"),u=0,c=0,p=0,f=0,d=0,h=0,g=[];e.config.thumbnail&&(u=e.config.thumbnail.pic_num,c=e.config.thumbnail.width,p=e.config.thumbnail.height,f=e.config.thumbnail.col,d=e.config.thumbnail.row,g=e.config.thumbnail.urls,s.style.width=c+"px",s.style.height=p+"px"),["touchstart","mousedown"].forEach(function(r){n.addEventListener(r,function(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),r._target===l||e.ended)return!1;n.focus(),o=n.getBoundingClientRect().width;var i=a.getBoundingClientRect().left,s=!1,u=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),s=!0;var r=n.clientX-i,l=r/o*e.duration;a.style.width=100*r/o+"%",e.currentTime=Number(l).toFixed(1)},c=function r(l){if(l.preventDefault(),l.stopPropagation(),t.event(l),window.removeEventListener("mousemove",u),window.removeEventListener("touchmove",u),window.removeEventListener("mouseup",r),window.removeEventListener("touchend",r),n.blur(),!s){var c=l.clientX-i,p=c/o*e.duration;a.style.width=100*c/o+"%",e.currentTime=Number(p).toFixed(1)}s=!1};return window.addEventListener("mousemove",u),window.addEventListener("touchmove",u),window.addEventListener("mouseup",c),window.addEventListener("touchend",c),!1})}),n.addEventListener("mouseenter",function(r){if(e.ended)return!1;var o=n.getBoundingClientRect().left,a=n.getBoundingClientRect().width,i=function(n){var r=(n.clientX-o)/a*e.duration;l.textContent=t.format(r);var i=l.getBoundingClientRect().width;if(e.config.thumbnail){h=e.duration/u;var y=Math.floor(r/h);s.style.backgroundImage="url("+g[Math.ceil((y+1)/(f*d))-1]+")";var v=y+1-f*d*(Math.ceil((y+1)/(f*d))-1),m=Math.ceil(v/d)-1,x=v-m*d-1;s.style["background-position"]="-"+x*c+"px -"+m*p+"px";var b=n.clientX-o-c/2;b=(b=b>0?b:0)0?w:0)>a-i?a-i:w,l.style.left=w+"px"}l.style.display="block"},y=function(e){i(e)};n.addEventListener("mousemove",y,!1),n.addEventListener("mouseleave",function e(t){n.removeEventListener("mousemove",y,!1),n.removeEventListener("mouseleave",e,!1),i(t),l.style.display="none",s.style.display="none"},!1),i(r)},!1),e.on("timeupdate",function(){!o&&n&&(o=n.getBoundingClientRect().width),a.style.width=100*e.currentTime/e.duration+"%"}),["cacheupdate","ended","timeupdate"].forEach(function(t){e.on(t,function(){var t=e.buffered;if(t&&t.length>0){var n=t.end(t.length-1);i.style.width=n/e.duration*100+"%"}})}),e.once("destroy",function(){n=null,a=null,l=null,s=null,i=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("poster",function(){var e=r.default.util.createDom("xg-poster","",{},"xgplayer-poster"),t=this.root;this.config.poster&&(e.style.backgroundImage="url("+this.config.poster+")",t.appendChild(e)),this.on("play",function(){e.style.display="none"}),this.once("destroy",function(){e=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("playbackRate",function(){var e=this,t=r.default.util,n=0,o=[];if(!e.config.playbackRate)return!1;e.config.playbackRate.sort(function(e,t){return e-t}),e.config.playbackRate.forEach(function(e,t){1!==e&&"1"!==e||(n=t),o.push(e+"x")});var a=e.config.lang&&"zh-cn"===e.config.lang?"倍速":"Speed",i=t.createDom("xg-playback",'

1x

',{},"xgplayer-playback"),l=e.controls,s=t.createDom("xg-tips",a,{},"xgplayer-tips");i.appendChild(s),l.appendChild(i),["touchstart","click"].forEach(function(t){i.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation();var r=t.target||t.srcElement;(r&&"p"===r.tagName.toLocaleLowerCase()||"span"===r.tagName.toLocaleLowerCase())&&(n=n+1===o.length?0:n+1,i.querySelector("p").innerHTML=""+o[n]+"",e.video.playbackRate=1*o[n].replace(/x$/g,""))},!1)}),i.addEventListener("mouseenter",function(t){t.preventDefault(),t.stopPropagation(),s.style.left="50%";var n=s.getBoundingClientRect(),r=e.root.getBoundingClientRect();n.right>r.right&&(s.style.left=-n.right+r.right+16+"px")}),e.once("destroy",function(){i=null})})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("play",function(){var e=this,t=e.controls,n=r.default.util,a=e.config.iconScale||.0320625,i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=n.createDom("xg-play",'\n \n '),u=e.config.lang&&"zh-cn"===e.config.lang?"播放":"Play",c=e.config.lang&&"zh-cn"===e.config.lang?"暂停":"Pause",p=n.createDom("xg-tips",u,{},"xgplayer-tips"),f=s.querySelector("path");s.appendChild(p);var d=new o.default({progress:function(e,t){f.setAttribute("d",d.toSVGString(e))},from:l,to:i});s.className="xgplayer-play",t.appendChild(s),["click","touchstart"].forEach(function(t){s.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.ended||(e.paused?e.play():e.pause())},!1)}),e.on("play",function(){p.textContent=c,d.to!==l&&d.reset(l,i)}),e.on("pause",function(){p.textContent=u,d.to!==i&&d.reset(i,l)}),e.once("destroy",function(){s=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("pc",function(){var e=this,t=r.default.util,n=e.controls,o=e.root,a=0,i=void 0,l="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",s="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",u=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),c=t.createDom("xg-enter",'',{},"xgplayer-enter"),p=c.querySelector(".xgplayer-enter-logo");o.appendChild(u),o.appendChild(c);var f=u.querySelector("path"),d=new Image;d.onload=function(){c.querySelector(".xgplayer-enter-tips").style.display="block"},e.config.enterLogo?(d.src=e.config.enterLogo,p.style.backgroundImage='url("'+e.config.enterLogo+'")'):d.src=t.getBgImage(p),["click","touchstart"].forEach(function(n){u.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),e.config.url&&(t.hasClass(o,"xgplayer-nostart")?(t.removeClass(o,"xgplayer-nostart"),t.addClass(o,"xgplayer-is-enter"),o.querySelector("video")||e.start(),e.on("canplay",function(){t.removeClass(o,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(o,"xgplayer-is-enter")}),e.play(),setTimeout(function(){e.play()},10)):e.paused&&(t.removeClass(o,"xgplayer-nostart xgplayer-isloading"),setTimeout(function(){e.play()},10)))})}),u.addEventListener("animationend",function(e){e.preventDefault(),t.removeClass(u,"xgplayer-start-interact"),u.style.display="none"}),e.on("play",function(){f.setAttribute("d",l),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.on("pause",function(){f.setAttribute("d",s),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.video.addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),document.activeElement===e.video?(a++,i&&clearTimeout(i),1===a?i=setTimeout(function(){if(t.hasClass(e.root,"xgplayer-nostart"))return!1;e.ended||(e.paused?e.play():e.pause()),a=0},200):a=0):e.video.focus()},!1),e.video.addEventListener("dblclick",function(t){if(t.preventDefault(),t.stopPropagation(),document.activeElement===e.video){var r=n.querySelector(".xgplayer-fullscreen");if(r){var o=void 0;document.createEvent?(o=document.createEvent("Event")).initEvent("click",!0,!0):o=new Event("click"),r.dispatchEvent(o)}}else e.video.focus()},!1),o.addEventListener("mouseenter",function(t){e.emit("focus",e)},!1),o.addEventListener("mouseleave",function(t){e.emit("blur",e)},!1),n.addEventListener("mouseenter",function(t){e.userTimer&&clearTimeout(e.userTimer)},!1),n.addEventListener("mouseleave",function(t){e.emit("focus",e)},!1)})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("mobile",function(){var e=this,t=r.default.util,n=e.root;e.config.autoplay=!1;var a=function(e){var t=r.default.util;return e.some(function(e){return"Function"===t.typeOf(e)?e.call(navigator.userAgent):"RegExp"===t.typeOf(e)?e.test(navigator.userAgent):"String"===t.typeOf(e)&&navigator.userAgent.indexOf(e)>-1})}(e.config.whitelist);e.mobilePass=a;var i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),u=t.createDom("xg-enter",'',{},"xgplayer-enter"),c=u.querySelector(".xgplayer-enter-logo");n.appendChild(s),n.appendChild(u);var p=s.querySelector("path"),f=new Image,d=new o.default({from:l,to:i,progress:function(e,t){p.setAttribute("d",d.toSVGString(e))}});u.querySelector(".xgplayer-enter-tips").style.display="block",e.start(),a?(e.config.enterLogo?(f.src=e.config.enterLogo,c.style.backgroundImage='url("'+e.config.enterLogo+'")'):f.src=t.getBgImage(c),e.video.addEventListener("touchstart",function(t){t.preventDefault(),e.emit("focus")},!1),s.addEventListener("touchend",function(r){r.preventDefault(),t.hasClass(n,"xgplayer-nostart")?(t.removeClass(n,"xgplayer-nostart"),t.addClass(n,"xgplayer-is-enter"),e.on("canplay",function(){t.removeClass(n,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(n,"xgplayer-is-enter")}),e.play()):e.paused?e.play():e.pause()}),e.on("play",function(){d.reset(l,i)}),e.on("pause",function(){d.reset(i,l)})):(t.addClass(n,"xgplayer-mobile-npassed"),e.once("ready",function(){e.video.controls=e.config.controls,e.video.controlsList=e.config.controlsList.join(" "),e.config.poster&&(e.video.poster=e.config.poster)})),e.config.debug&&function(e){var t={};Object.assign(t,{host:"127.0.0.1",port:9090},e);var n=document.createElement("script"),r=document.createElement("h4");r.style.cssText="position:fixed;bottom:0;padding:10px;width:100%;background-color:#fff;text-align:center",r.textContent="weinre --boundHost "+t.host+" --httpPort "+t.port+"\r\n 启动服务后,刷新页面",n.anonymous=!0,n.async=!0,n.src="http://"+t.host+":"+t.port+"/target/target-script-min.js#anonymous",n.onload=function(){r.parentNode.removeChild(r)},document.body.appendChild(n),document.body.appendChild(r)}(e.config.debug)})},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;ni.length){for(var c=function(e){i[e]={id:e,queue:[],step:t.channels[e].step,surplus:t.channels[e].surplus},t.channels[e].queue.forEach(function(t){return i[e].queue.push(t)})},p=0;pn.length)return{result:!1,message:"exceed channels.length, occupy="+o+",channelsSize="+n.length};for(var a=!0,i=void 0,l=-1,s=0,u=n.length;s-1&&(r.queue.splice(i,1),0===i&&(r.step=9999,r.surplus=0))}}},{key:"update",value:function(){var e=this.channels,t=this.width;e.forEach(function(e){var n=e.queue[0];n?e.surplus=t-n.left-n.width:(e.step=9999,e.surplus=0)})}},{key:"reset",value:function(){var e=this.player.root,t=this;setTimeout(function(){var n=e.querySelector(".xgplayer-bullet"),r=n.getBoundingClientRect();t.width=r.width,t.height=r.height,t.container=n;for(var o=/mobile/gi.test(navigator.userAgent)?10:12,a=Math.floor(t.height/o),i=[],l=0;l0?e.map(function(e){return{id:e.danmaku_id,txt:e.text.slice(0,40),duration:1*e.duration,color:e.text_color.replace("0x","#"),scale:1*e.text_scale,start:1*e.offset_time}}):[]}},n),t.on("dataIncoming",this.dataHandle.bind(this)),t.on("seeked",this.seekHandle.bind(this)),t.on("bullet_remove",this.updateQueue.bind(this)),t.on("ended",this.stop.bind(this)),t.on("pause",this.pause.bind(this)),t.on("play",this.play.bind(this))}return r(e,[{key:"updateQueue",value:function(e){var t=this;t.queue.some(function(n,r){if(n.id===e.bullet.id)return t.queue.splice(r,1),!0})}},{key:"init",value:function(){var e=this;if(e.data)return e.player.paused?void(e.status="paused"):e.player.ended?void(e.status="ended"):(e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),void e.player.emit("dataIncoming"));fetch(e.options.url,{method:e.options.method,headers:{Accept:"application/json"}}).then(function(t){t.ok&&t.json().then(function(t){var n=e.options.dataMap.call(null,t.data);if(n.length){e.data=n;var r=document.createElement("span");r.style.padding=e.options.padding+"||'0px'",r.style.position="absolute",r.style.left="-99999px",document.body.appendChild(r);var o=void 0;if(e.data.forEach(function(e){r.textContent=e.txt,r.style.fontSize=20*e.scale+"px",o=r.getBoundingClientRect(),e.width=o.width,e.height=o.height}),e.data.sort(function(e,t){return e.start-t.start}),document.body.removeChild(r),e.player.paused)return void(e.status="paused");if(e.player.ended)return void(e.status="ended");e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),e.player.emit("dataIncoming")}})}).catch(function(e){console.log("Fetch错误:"+e)})}},{key:"start",value:function(){this.status="playing",this.channel.reset(),this.init()}},{key:"stop",value:function(){this.status="closed",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer),this.queue.length=0,this.container.innerHTML=""}},{key:"play",value:function(){var e=this,t=o.default.util;"idle"===e.status||"ended"===e.status?t.hasClass(e.container,"xgplayer-has-bullet")&&e.start():"paused"===e.status&&t.hasClass(e.container,"xgplayer-has-bullet")&&(e.status="playing",e.dataHandle(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3))}},{key:"pause",value:function(){"playing"===this.status?(this.status="paused",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer)):"ended"===this.status&&this.stop()}},{key:"dataHandle",value:function(){var e=(0,a.default)("cancel");if(e(this.timer),this.queue.length){this.queue.forEach(function(e){"waiting"!==e.status&&"start"!==e.status||(e.status="start",e.move())});var t=(0,a.default)("request");this.timer=t(this.dataHandle.bind(this))}else e(this.timer)}},{key:"readData",value:function(){var e=this,t=this.player,n=this.formatTime(t.currentTime),r=void 0,o=e.interval,a=e.channel,i=e.container,l=e.data.filter(function(e){return e.start<=n&&n<=e.start+o});l.length>0&&l.forEach(function(n){r=new c(t,i,n),a.addBullet(r).result&&(e.queue.push(r),r.reset(),r.attach())})}},{key:"seekHandle",value:function(){o.default.util;this.stop(),this.player.paused?this.status="idle":(this.status="playing",this.channel.resetWithCb(),this.init())}},{key:"formatTime",value:function(e){var t=Math.floor(e);return 1e3*t+(e-t)}}]),e}(),f=function(){function e(t,n){s(this,e);var r=this;this.player=t,this.el_=this.createEl(),this.onceFlag=!1;["click","touchstart"].forEach(function(e){r.el_.addEventListener(e,function(e){e.preventDefault(),e.stopPropagation(),r.onClick()},!1)}),this.main=new p(t,n),"on"===n.switch&&this.player.once("play",function(){r.onChange(!0)})}return r(e,[{key:"createEl",value:function(){return o.default.util.createDom("xg-bullet-btn",'',{},"xgplayer-bullet-btn "+("on"===this.player.config.bullet.switch?"xgplayer-bullet-btn-active":""))}},{key:"onClick",value:function(){var e=this,t=o.default.util;t.toggleClass(e.el_,"xgplayer-bullet-btn-active");var n=!!t.hasClass(e.el_,"xgplayer-bullet-btn-active");function r(){e.onceFlag=!1,e.main.channel.resetWithCb(e.onChange.bind(e))}n?e.player.paused||e.player.ended?this.onceFlag||(this.onceFlag=!0,this.player.once("play",r)):r():(this.player.off("play",r),this.onChange(n))}},{key:"onChange",value:function(e){var t=o.default.util,n=this.player.root.querySelector(".xgplayer-bullet");e?(t.addClass(n,"xgplayer-has-bullet"),this.main.start()):(t.removeClass(n,"xgplayer-has-bullet"),this.main.stop())}}]),e}();o.default.install("makeBullet",function(){var e=this,t=o.default.util;if(e.config.bullet){var n=t.createDom("xg-bullet","",{},"xgplayer-bullet");e.root.appendChild(n);var r=new f(e,e.config.bullet);["touchstart","click"].forEach(function(t){n.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.paused?e.play():e.pause()},!1)}),e.controls.appendChild(r.el_)}})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}; +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xgplayer=t():e.xgplayer=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:this.config.url,n=this.root,r=this;"String"===a.default.typeOf(t)?this.video.src=t:t.forEach(function(t){e.video.appendChild(a.default.createDom("source","",{src:""+t.src,type:""+(t.type||"")}))}),n.insertBefore(this.video,n.firstChild),r.userTimer=setTimeout(function(){r.emit("blur")},r.config.inactive),setTimeout(function(){e.emit("complete")},1)}},{key:"reload",value:function(){this.video.load(),this.once("loadeddata",function(){this.play()})}},{key:"destroy",value:function(){var e=this,t=this.root.parentNode;if(this.ev.forEach(function(t){var n=Object.keys(t)[0],r=e[t[n]];r&&e.off(n,r)}),["focus","blur"].forEach(function(t){e.off(t,e["on"+t.charAt(0).toUpperCase()+t.slice(1)])}),this.paused)for(var n in this.emit("destroy"),t.removeChild(this.root),t.appendChild(this.rootBackup),this)"config"!==n&&delete this[n];else this.pause(),this.once("pause",function(){for(var n in e.emit("destroy"),t.removeChild(e.root),t.appendChild(e.rootBackup),e)"config"!==n&&delete e[n]})}},{key:"replay",value:function(){var e=this._replay;a.default.removeClass(this.root,"xgplayer-ended"),e&&e instanceof Function?e():(this.currentTime=0,this.play())}},{key:"onFocus",value:function(){var e=this;a.default.removeClass(this.root,"xgplayer-inactive"),e.userTimer&&clearTimeout(e.userTimer),e.userTimer=setTimeout(function(){e.emit("blur")},e.config.inactive)}},{key:"onBlur",value:function(){this.paused||this.ended||a.default.addClass(this.root,"xgplayer-inactive")}},{key:"onPlay",value:function(){a.default.addClass(this.root,"xgplayer-playing"),a.default.removeClass(this.root,"xgplayer-pause")}},{key:"onPause",value:function(){a.default.addClass(this.root,"xgplayer-pause"),this.userTimer&&clearTimeout(this.userTimer),this.emit("focus")}},{key:"onEnded",value:function(){a.default.addClass(this.root,"xgplayer-ended"),a.default.removeClass(this.root,"xgplayer-playing")}},{key:"onSeeking",value:function(){}},{key:"onSeeked",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading")}},{key:"onWaiting",value:function(){var e=this;e.waitTimer&&clearTimeout(e.waitTimer),e.waitTimer=setTimeout(function(){a.default.addClass(e.root,"xgplayer-isloading")},500)}},{key:"onPlaying",value:function(){this.waitTimer&&clearTimeout(this.waitTimer),a.default.removeClass(this.root,"xgplayer-isloading xgplayer-nostart xgplayer-pause xgplayer-ended xgplayer-is-error xgplayer-replay"),a.default.addClass(this.root,"xgplayer-playing")}}],[{key:"install",value:function(e,n){t.plugins||(t.plugins={}),t.plugins[e]=n}}]),t}();p.util=a.default,p.sniffer=i.default,p.Errors=l.default,t.default=p,e.exports=t.default},function(e,t,n){"use strict";var r=n(17)();e.exports=function(e){return e!==r&&null!==e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.from=t.from,this.to=t.to,this.easing=t.easing||function(e){return e*e},this.duration=t.duration||150,this.curPath="",this.progress=t.progress,this.state=0}return r(e,[{key:"animate",value:function(){var e=this,t=new Date,n=e.duration,r=null,o=e.path2shapes(e.from),a=e.path2shapes(e.to),i=e._preprocessing(o,a);e.state=1;!function o(){var l=new Date-t;if(l>=n||2===e.state)return r=a,e.progress(r,1),window.cancelAnimationFrame(e.tickId),void(e.state=0);var s=e.easing(l/n);r=e._lerp(i[0],i[1],s),e.progress(r,s),e.tickId=window.requestAnimationFrame(o)}()}},{key:"toSVGString",value:function(e){return e.map(function(e){return e.forEach(function(e,t){t?e.splice(0,2,"C"):(e.splice(2,0,"C"),e.unshift("M"))}),e.map(function(e){return e.join(" ")}).join("")}).join("")}},{key:"start",value:function(){self.animate()}},{key:"stop",value:function(){0!==this.state&&(this.state=2),window.cancelAnimationFrame(self.tickId),this.state=0}},{key:"reverse",value:function(){0!==this.state&&this.stop();var e=this.from;this.from=this.to,this.to=e,this.animate()}},{key:"reset",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.from;0!==this.state&&this.stop(),this.from=t,this.to=e,this.animate()}}]),e}();for(var i in o.default)o.default[i]instanceof Function&&!a.prototype[i]&&(a.prototype[i]=o.default[i]);t.default=a,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={createDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",o=document.createElement(e);return o.className=r,o.innerHTML=t,Object.keys(n).forEach(function(t){var r=t,a=n[t];"video"===e||"audio"===e?a&&o.setAttribute(r,a):o.setAttribute(r,a)}),o},hasClass:function(e,t){return e.classList?Array.prototype.some.call(e.classList,function(e){return e===t}):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:function(e,t){e.classList?t.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(t){t&&e.classList.add(t)}):r.hasClass(e,t)||(e.className+=" "+t)},removeClass:function(e,t){e.classList?t.split(/\s+/g).forEach(function(t){e.classList.remove(t)}):r.hasClass(e,t)&&t.split(/\s+/g).forEach(function(t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")})},toggleClass:function(e,t){t.split(/\s+/g).forEach(function(t){r.hasClass(e,t)?r.removeClass(e,t):r.addClass(e,t)})},findDom:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=arguments[1];return e.querySelector(t)},padStart:function(e,t,n){for(var r=String(n),o=t>>0,a=Math.ceil(o/r.length),i=[],l=String(e);a--;)i.push(r);return i.join("").substring(0,o-l.length)+l},format:function(e){if(window.isNaN(e))return"";var t=r.padStart(Math.floor(e/3600),2,0),n=r.padStart(Math.floor((e-3600*t)/60),2,0),o=r.padStart(Math.floor(e-3600*t-60*n),2,0);return("00"===t?[n,o]:[t,n,o]).join(":")},event:function(e){if(e.touches){var t=e.touches[0]||e.changedTouches[0];e.clientX=t.clientX||0,e.clientY=t.clientY||0,e.offsetX=t.pageX-t.target.offsetLeft,e.offsetY=t.pageY-t.target.offsetTop}e._target=e.target||e.srcElement},typeOf:function(e){return Object.prototype.toString.call(e).match(/([^\s.*]+)(?=]$)/g)[0]},deepCopy:function(e,t){if("Object"===r.typeOf(t)&&"Object"===r.typeOf(e))return Object.keys(t).forEach(function(n){"Object"!==r.typeOf(t[n])||t[n]instanceof Node?e[n]=t[n]:e[n]?r.deepCopy(e[n],t[n]):e[n]=t[n]}),e},getBgImage:function(e){var t=document.createElement("a"),n=(e.currentStyle||window.getComputedStyle(e,null)).backgroundImage;return t.href=n.replace(/url\("|"\)/g,""),t.href},copyDom:function(e){if(e&&1===e.nodeType){var t=document.createElement(e.tagName);return Array.prototype.forEach.call(e.attributes,function(e){t.setAttribute(e.name,e.value)}),t}return""}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(5);var o={network:{code:1,msg:"视频下载错误",remark:"只要视频下载错误就使用此类型,无论是video本身的超时还是xhr的分段请求超时或者资源不存在"},mse:{code:2,msg:"流追加错误",remark:"追加流的时候如果类型不对、无法被正确解码则会触发此类错误"},parse:{code:3,msg:"解析错误",remark:"mp4、hls、flv我们都是使用js进行格式解析,如果解析失败则会触发此类错误"},format:{code:4,msg:"格式错误",remark:"如果浏览器不支持的格式导致播放错误"},decoder:{code:5,msg:"解码错误",remark:"浏览器解码异常会抛出此类型错误"},runtime:{code:6,msg:"语法错误",remark:"播放器语法错误"},timeout:{code:7,msg:"播放超时",remark:"播放过程中无法正常请求下一个分段导致播放中断"},other:{code:8,msg:"其他错误",remark:"不可知的错误或被忽略的错误类型"}};t.default=function e(t,n,a,i,l,s,u,c){var p=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{line:"",handle:"",msg:"",version:""};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var f={};return f.playerVersion=r.version,f.errorType=t,f.domain=document.domain,f.duration=a,f.currentTime=n,f.networkState=i,f.readyState=l,f.currentSrc=u,f.src=s,f.ended=c,f.errd=p,f.ex=(o[t]||{}).msg,f},e.exports=t.default},function(e){e.exports={name:"xgplayer",version:"1.0.7",description:"video player",main:"./dist/index.js",scripts:{prepare:"npm run build",build:"webpack --progress --display-chunks -p",watch:"webpack --progress --display-chunks -p --watch"},keywords:["video","player"],babel:{presets:["es2015"],plugins:["add-module-exports","babel-plugin-bulk-import"]},repository:{type:"git",url:"git+https://github.com/bytedance/xgplayer.git"},author:"yinguohui@bytedance.com",license:"MIT",dependencies:{"babel-plugin-add-module-exports":"^0.2.1",deepmerge:"^1.5.0","event-emitter":"^0.3.5",pasition:"^1.0.1","request-frame":"^1.5.3"},browserslist:["> 5%","IE 9","iOS 7","Firefox > 20"],devDependencies:{"babel-loader":"^7.1.4","babel-plugin-bulk-import":"^1.0.2","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-runtime":"^6.23.0","babel-preset-es2015":"^6.24.1","core-js":"^2.5.4","css-loader":"^0.28.11","json-loader":"^0.5.7","node-sass":"^4.8.3","postcss-cssnext":"^3.1.0","postcss-loader":"^2.1.5","sass-loader":"^6.0.7","style-loader":"^0.20.3",sugarss:"^1.0.1",webpack:"^4.8.1","webpack-cli":"^2.1.3",zlib:"^1.0.5"}}},function(e,t,n){e.exports=n(7)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=w(n(0)),o=w(n(26)),a=w(n(29)),i=w(n(30)),l=w(n(31)),s=w(n(32)),u=w(n(33)),c=w(n(34)),p=w(n(35)),f=w(n(36)),d=w(n(37)),h=w(n(38)),g=w(n(41)),y=w(n(42)),v=w(n(43)),m=w(n(44)),x=w(n(45)),b=w(n(46));function w(e){return e&&e.__esModule?e:{default:e}}n(47);var k={};function E(e,t,n){var r=e;t.map(function(e,o){r[e]=o==t.length-1?n:r[e]||{},r=r[e]})}E(k,["control","definition"],b.default),E(k,["control","error"],x.default),E(k,["control","flex"],m.default),E(k,["control","fullscreen"],v.default),E(k,["control","i18n"],y.default),E(k,["control","loading"],g.default),E(k,["control","makeBullet"],h.default),E(k,["control","mobile"],d.default),E(k,["control","pc"],f.default),E(k,["control","play"],p.default),E(k,["control","playbackRate"],c.default),E(k,["control","poster"],u.default),E(k,["control","progress"],s.default),E(k,["control","replay"],l.default),E(k,["control","textTrack"],i.default),E(k,["control","time"],a.default),E(k,["control","volume"],o.default),t.default=r.default,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n",!0}),r.crossorigin="anonymous"),t.textTrackStyle){var s=document.createElement("style");document.head.appendChild(s);var u="";for(var c in t.textTrackStyle)u+=c+": "+t.textTrackStyle[c]+";";var p=t.id?"#"+t.id:t.el.id?"#"+t.el.id:"."+t.el.className;s.sheet.addRule(p+" video::cue",u),s.sheet.insertRule(p+" video::cue { "+u+" }",0)}this.video=a.default.createDom(r.mediaType,l,r,""),this.ev=["play","playing","pause","ended","error","seeking","seeked","timeupdate","waiting","canplay","canplaythrough","durationchange","volumechange","loadeddata"].map(function(e){return function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}({},e,"on"+e.charAt(0).toUpperCase()+e.slice(1))}),(0,o.default)(this),this.ev.forEach(function(e){var t=n,r=Object.keys(e)[0];t.video.addEventListener(r,function(){"play"===r&&(t.hasStart=!0),"error"===r?t.video.error&&t.emit(r,new i.default("other",t.currentTime,t.duration,t.networkState,t.readyState,t.currentSrc,t.src,t.ended,{line:41,msg:t.error,handle:"Constructor"})):t.emit(r,t)},!1)})}return r(e,[{key:"play",value:function(){this.video.play()}},{key:"pause",value:function(){this.video.pause()}},{key:"canPlayType",value:function(){this.video.canPlayType()}},{key:"getBufferedRange",value:function(){var e=[0,0],t=this.video,n=t.buffered,r=t.currentTime;if(n)for(var o=0,a=n.length;o-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r={get device(){var e=r.os;return e.isPc?"pc":e.isTablet?"tablet":"mobile"},get browser(){var e=navigator.userAgent.toLowerCase(),t={ie:/rv:([\d.]+)\) like gecko/,firfox:/firefox\/([\d.]+)/,chrome:/chrome\/([\d.]+)/,opera:/opera.([\d.]+)/,safari:/version\/([\d.]+).*safari/};return[].concat(Object.keys(t).filter(function(n){return t[n].test(e)}))[0]},get os(){var e=navigator.userAgent,t=/(?:Windows Phone)/.test(e),n=/(?:SymbianOS)/.test(e)||t,r=/(?:Android)/.test(e),o=/(?:Firefox)/.test(e),a=/(?:iPad|PlayBook)/.test(e)||r&&!/(?:Mobile)/.test(e)||o&&/(?:Tablet)/.test(e),i=/(?:iPhone)/.test(e)&&!a;return{isTablet:a,isPhone:i,isAndroid:r,isPc:!i&&!r&&!n,isSymbian:n,isWindowsPhone:t,isFireFox:o}}};t.default=r,e.exports=t.default},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("volume",function(){var e=this,t=r.default.util,n=e.config.volume,a={muted:"M920.4 439.808l-108.544-109.056-72.704 72.704 109.568 108.544-109.056 108.544 72.704 72.704 108.032-109.568 108.544 109.056 72.704-72.704-109.568-108.032 109.056-108.544-72.704-72.704-108.032 109.568z",small:"M795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z",large:"M940.632 837.632l-72.192-72.192c65.114-64.745 105.412-154.386 105.412-253.44s-40.299-188.695-105.396-253.424l-0.016-0.016 72.192-72.192c83.639 83.197 135.401 198.37 135.401 325.632s-51.762 242.434-135.381 325.612l-0.020 0.020zM795.648 693.248l-72.704-72.704c27.756-27.789 44.921-66.162 44.921-108.544s-17.165-80.755-44.922-108.546l0.002 0.002 72.704-72.704c46.713 46.235 75.639 110.363 75.639 181.248s-28.926 135.013-75.617 181.227l-0.021 0.021z"},i=function(e){return 0===e?"muted":e<.5?"small":"large"},l=a[i(n)],s=a[i(n)],u=t.createDom("xg-volume",'\n \n \n \n \n \n \n \n \n \n ',{},"xgplayer-volume"),c=e.controls;c.appendChild(u);var p=void 0,f=u.querySelector(".xgplayer-slider"),d=u.querySelector(".xgplayer-bar"),h=u.querySelector(".xgplayer-drag"),g=u.querySelector(".xgplayer-icon");h.style.height=100*e.config.volume+"%";var y=c.querySelectorAll("path")[1],v=new o.default({progress:function(e,t){var n=v.toSVGString(e);y.setAttribute("d",n),l=n},from:l,to:a.large}),m=null;f.volume=e.config.volume,["touchstart","mousedown"].forEach(function(n){d.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),f.focus(),t.event(n),p=d.getBoundingClientRect().height,n.clientX;var r=n.clientY,o=h.getBoundingClientRect().height,a=!1,i=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),a=!0;var i=o-n.clientY+r,l=i/p;h.style.height=i+"px",e.volume=Math.max(Math.min(l,1),.01)},l=function n(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),window.removeEventListener("mousemove",i),window.removeEventListener("touchmove",i),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),m||(m=d.getBoundingClientRect()),!a){var o=m.height-(r.clientY-m.top),l=o/m.height;h.style.height=o+"px",l<=0&&(e.volume>0?h.volume=e.video.volume:l=h.volume),e.volume=Math.max(Math.min(l,1),.01)}f.volume=e.volume,a=!1};return window.addEventListener("mousemove",i),window.addEventListener("touchmove",i),window.addEventListener("mouseup",l),window.addEventListener("touchend",l),!1})}),["touchstart","mousedown"].forEach(function(n){g.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),t.hasClass(f,"xgplayer-none")?(t.removeClass(f,"xgplayer-none"),f.focus()):0===e.volume?e.volume=f.volume:e.volume=0})}),f.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.addClass(f,"xgplayer-none")});var x=null;e.on("volumechange",function(){x&&clearTimeout(x),x=setTimeout(function(){v.reset(a[i(e.volume)],l),l=a[i[e.volume]],p||(p=d.getBoundingClientRect().height||76),h.style.height=e.volume*p+"px"},50)}),e.once("canplay",function(){e.volume=e.config.volume}),e.once("destroy",function(){u=null,h=null})})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(i,l){"object"===a(t)&&void 0!==e?e.exports=l():void 0===(o="function"==typeof(r=l)?r.call(t,n,t,e):r)||(e.exports=o)}(0,function(){var e=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{!r&&l.return&&l.return()}finally{if(o)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),t=2*Math.PI,n=function(e,t,n,r,o,a,i){var l=e.x,s=e.y;return{x:r*(l*=t)-o*(s*=n)+a,y:o*l+r*s+i}},r=function(e,t){var n=4/3*Math.tan(t/4),r=Math.cos(e),o=Math.sin(e),a=Math.cos(e+t),i=Math.sin(e+t);return[{x:r-o*n,y:o+r*n},{x:a+i*n,y:i-a*n},{x:a,y:i}]},o=function(e,t,n,r){var o=e*r-t*n<0?-1:1,a=(e*n+t*r)/(Math.sqrt(e*e+t*t)*Math.sqrt(e*e+t*t));return a>1&&(a=1),a<-1&&(a=-1),o*Math.acos(a)},a=function(a){var i=a.px,l=a.py,s=a.cx,u=a.cy,c=a.rx,p=a.ry,f=a.xAxisRotation,d=void 0===f?0:f,h=a.largeArcFlag,g=void 0===h?0:h,y=a.sweepFlag,v=void 0===y?0:y,m=[];if(0===c||0===p)return[];var x=Math.sin(d*t/360),b=Math.cos(d*t/360),w=b*(i-s)/2+x*(l-u)/2,k=-x*(i-s)/2+b*(l-u)/2;if(0===w&&0===k)return[];c=Math.abs(c),p=Math.abs(p);var E=Math.pow(w,2)/Math.pow(c,2)+Math.pow(k,2)/Math.pow(p,2);E>1&&(c*=Math.sqrt(E),p*=Math.sqrt(E));var C=function(e,n,r,a,i,l,s,u,c,p,f,d){var h=Math.pow(i,2),g=Math.pow(l,2),y=Math.pow(f,2),v=Math.pow(d,2),m=h*g-h*v-g*y;m<0&&(m=0),m/=h*v+g*y;var x=(m=Math.sqrt(m)*(s===u?-1:1))*i/l*d,b=m*-l/i*f,w=p*x-c*b+(e+r)/2,k=c*x+p*b+(n+a)/2,E=(f-x)/i,C=(d-b)/l,_=(-f-x)/i,T=(-d-b)/l,M=o(1,0,E,C),S=o(E,C,_,T);return 0===u&&S>0&&(S-=t),1===u&&S<0&&(S+=t),[w,k,M,S]}(i,l,s,u,c,p,g,v,x,b,w,k),_=e(C,4),T=_[0],M=_[1],S=_[2],A=_[3],R=Math.max(Math.ceil(Math.abs(A)/(t/4)),1);A/=R;for(var L=0;Le-1&&(a-=e),r[a]=o}t.push(r)}return t})(e.length).forEach(function(r){var o=0,a=0;r.forEach(function(n){o+=function(e,t){var n=e[0],r=e[2],o=e[4],a=e[6],i=e[1],l=e[3],s=e[5],u=e[7],c=t[0],p=t[2],f=t[4],d=t[6],h=t[1],g=t[3],y=t[5],v=t[7];return Math.sqrt(Math.pow(c-n,2)+Math.pow(h-i,2))+Math.sqrt(Math.pow(p-r,2)+Math.pow(g-l,2))+Math.sqrt(Math.pow(f-o,2)+Math.pow(y-s,2))+Math.sqrt(Math.pow(d-a,2)+Math.pow(v-u,2))}(e[n],t[a++])}),n.push({index:r,distance:o})}),n.sort(function(e,t){return e.distance-t.distance});var r=[];return n[0].index.forEach(function(t){r.push(e[t])}),r}function p(e,t){var n=[];(function(e){for(var t=[],n=0;n2&&(t.push([n].concat(r.splice(0,2))),o="l",n="m"==n?"l":"L");;){if(r.length==i[o])return r.unshift(n),t.push(r);if(r.lengtho-1&&(r-=o)},f._splitCurves=function(e,t){for(var n=0,r=0;n=e.length-1&&(r=0)}},f._upShapes=function(e,t){for(var n=function(t){var n=[];e[e.length-1].forEach(function(e){n.push(e.slice(0))}),e.push(n)},r=0;rr?f._subShapes(o,a,n-r):nr?n=p)return i(c=n,1),a(c),void cancelAnimationFrame(u);var l=s(t/p);c=f._lerp(r[0],r[1],l),i(c,l),u=requestAnimationFrame(e)}()},f})},function(e,t,n){"use strict";!function(){for(var e=0,t=["webkit","moz"],n=0;n"+(e.currentTime||n(0))+""+(e.duration||n(0))+"",{},"xgplayer-time");e.controls.appendChild(o);var a=function(){o.innerHTML=""+n(e.currentTime||0)+""+n(e.duration)};e.on("durationchange",a),e.on("timeupdate",a),e.once("destroy",function(){e.off("durationchange",a),e.off("timeupdate",a),o=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("textTrack",function(){var e=this,t=r.default.util,n=(r.default.sniffer,t.createDom("xg-textTrack","",{tabindex:7},"xgplayer-textTrack")),o=e.controls,a=e.config.textTrack;a&&a instanceof Array&&a.length>1&&(t.addClass(e.root,"xgplayer-is-textTrack"),e.on("canplay",function(){var t=["
    "];t.push("
  • 关闭
  • "),a.forEach(function(e){t.push("
  • "+e.label+"
  • ")});var r=e.config.lang&&"zh-cn"===e.config.lang?"字幕":"Caption";t.push('

'+r+"

");var i=o.querySelector(".xgplayer-textTrack");i?i.innerHTML=t.join(""):(n.innerHTML=t.join(""),o.appendChild(n))})),["touchstart","click"].forEach(function(r){n.addEventListener(r,function(r){r.preventDefault(),r.stopPropagation();var o=r.target||r.srcElement;if(o&&"li"===o.tagName.toLocaleLowerCase()){Array.prototype.forEach.call(o.parentNode.childNodes,function(e){t.removeClass(e,"textTrack")}),t.addClass(o,"textTrack");var i=e.root.getElementsByTagName("Track");"关闭"===o.innerHTML?i[0].track.mode="hidden":(i[0].track.mode="showing",a.some(function(e){if(e.label===o.innerHTML)return i[0].src=e.src,e.kind&&(i[0].kind=e.kind),i[0].label=e.label,e.srclang&&(i[0].srclang=e.srclang),!0}),e.emit("textTrackChange",o.innerHTML))}else!o||"p"!==o.tagName.toLocaleLowerCase()&&"em"!==o.tagName.toLocaleLowerCase()||(t.addClass(n,"xgplayer-textTrack-active"),n.focus())},!1)}),n.addEventListener("blur",function(e){e.preventDefault(),e.stopPropagation(),t.removeClass(n,"xgplayer-textTrack-active")}),e.once("destroy",function(){n=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("replay",function(){var e=this,t=r.default.util,n=t.createDom("xg-replay",'\n \n \n \n 重播\n ',{},"xgplayer-replay"),o=e.root,a=n.querySelector(".xgplayer-replay-svg");o.appendChild(n),e.on("ended",function(){n.querySelector(".xgplayer-replay-txt").textContent=e.lang.REPLAY,e.config.loop||t.addClass(o,"replay")}),a.addEventListener("click",function(n){n.preventDefault(),t.removeClass(o,"replay"),e.replay()}),e.once("destroy",function(){a=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("progress",function(){var e=this,t=r.default.util,n=t.createDom("xg-progress",'',{tabindex:1},"xgplayer-progress"),o=void 0;e.controls.appendChild(n);var a=n.querySelector(".xgplayer-progress-played"),i=n.querySelector(".xgplayer-progress-cache"),l=n.querySelector(".xgplayer-progress-point"),s=n.querySelector(".xgplayer-progress-thumbnail"),u=0,c=0,p=0,f=0,d=0,h=0,g=[];e.config.thumbnail&&(u=e.config.thumbnail.pic_num,c=e.config.thumbnail.width,p=e.config.thumbnail.height,f=e.config.thumbnail.col,d=e.config.thumbnail.row,g=e.config.thumbnail.urls,s.style.width=c+"px",s.style.height=p+"px"),["touchstart","mousedown"].forEach(function(r){n.addEventListener(r,function(r){if(r.preventDefault(),r.stopPropagation(),t.event(r),r._target===l||e.ended)return!1;n.focus(),o=n.getBoundingClientRect().width;var i=a.getBoundingClientRect().left,s=!1,u=function(n){n.preventDefault(),n.stopPropagation(),t.event(n),s=!0;var r=n.clientX-i,l=r/o*e.duration;a.style.width=100*r/o+"%",e.currentTime=Number(l).toFixed(1)},c=function r(l){if(l.preventDefault(),l.stopPropagation(),t.event(l),window.removeEventListener("mousemove",u),window.removeEventListener("touchmove",u),window.removeEventListener("mouseup",r),window.removeEventListener("touchend",r),n.blur(),!s){var c=l.clientX-i,p=c/o*e.duration;a.style.width=100*c/o+"%",e.currentTime=Number(p).toFixed(1)}s=!1};return window.addEventListener("mousemove",u),window.addEventListener("touchmove",u),window.addEventListener("mouseup",c),window.addEventListener("touchend",c),!1})}),n.addEventListener("mouseenter",function(r){if(e.ended)return!1;var o=n.getBoundingClientRect().left,a=n.getBoundingClientRect().width,i=function(n){var r=(n.clientX-o)/a*e.duration;l.textContent=t.format(r);var i=l.getBoundingClientRect().width;if(e.config.thumbnail){h=e.duration/u;var y=Math.floor(r/h);s.style.backgroundImage="url("+g[Math.ceil((y+1)/(f*d))-1]+")";var v=y+1-f*d*(Math.ceil((y+1)/(f*d))-1),m=Math.ceil(v/d)-1,x=v-m*d-1;s.style["background-position"]="-"+x*c+"px -"+m*p+"px";var b=n.clientX-o-c/2;b=(b=b>0?b:0)0?w:0)>a-i?a-i:w,l.style.left=w+"px"}l.style.display="block"},y=function(e){i(e)};n.addEventListener("mousemove",y,!1),n.addEventListener("mouseleave",function e(t){n.removeEventListener("mousemove",y,!1),n.removeEventListener("mouseleave",e,!1),i(t),l.style.display="none",s.style.display="none"},!1),i(r)},!1),e.on("timeupdate",function(){!o&&n&&(o=n.getBoundingClientRect().width),a.style.width=100*e.currentTime/e.duration+"%"}),["cacheupdate","ended","timeupdate"].forEach(function(t){e.on(t,function(){var t=e.buffered;if(t&&t.length>0){var n=t.end(t.length-1);i.style.width=n/e.duration*100+"%"}})}),e.once("destroy",function(){n=null,a=null,l=null,s=null,i=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("poster",function(){var e=r.default.util.createDom("xg-poster","",{},"xgplayer-poster"),t=this.root;this.config.poster&&(e.style.backgroundImage="url("+this.config.poster+")",t.appendChild(e)),this.on("play",function(){e.style.display="none"}),this.once("destroy",function(){e=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("playbackRate",function(){var e=this,t=r.default.util,n=0,o=[];if(!e.config.playbackRate)return!1;e.config.playbackRate.sort(function(e,t){return e-t}),e.config.playbackRate.forEach(function(e,t){1!==e&&"1"!==e||(n=t),o.push(e+"x")});var a=e.config.lang&&"zh-cn"===e.config.lang?"倍速":"Speed",i=t.createDom("xg-playback",'

1x

',{},"xgplayer-playback"),l=e.controls,s=t.createDom("xg-tips",a,{},"xgplayer-tips");i.appendChild(s),l.appendChild(i),["touchstart","click"].forEach(function(t){i.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation();var r=t.target||t.srcElement;(r&&"p"===r.tagName.toLocaleLowerCase()||"span"===r.tagName.toLocaleLowerCase())&&(n=n+1===o.length?0:n+1,i.querySelector("p").innerHTML=""+o[n]+"",e.video.playbackRate=1*o[n].replace(/x$/g,""))},!1)}),i.addEventListener("mouseenter",function(t){t.preventDefault(),t.stopPropagation(),s.style.left="50%";var n=s.getBoundingClientRect(),r=e.root.getBoundingClientRect();n.right>r.right&&(s.style.left=-n.right+r.right+16+"px")}),e.once("destroy",function(){i=null})})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("play",function(){var e=this,t=e.controls,n=r.default.util,a=e.config.iconScale||.0320625,i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=n.createDom("xg-play",'\n \n '),u=e.config.lang&&"zh-cn"===e.config.lang?"播放":"Play",c=e.config.lang&&"zh-cn"===e.config.lang?"暂停":"Pause",p=n.createDom("xg-tips",u,{},"xgplayer-tips"),f=s.querySelector("path");s.appendChild(p);var d=new o.default({progress:function(e,t){f.setAttribute("d",d.toSVGString(e))},from:l,to:i});s.className="xgplayer-play",t.appendChild(s),["click","touchstart"].forEach(function(t){s.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.ended||(e.paused?e.play():e.pause())},!1)}),e.on("play",function(){p.textContent=c,d.to!==l&&d.reset(l,i)}),e.on("pause",function(){p.textContent=u,d.to!==i&&d.reset(i,l)}),e.once("destroy",function(){s=null})})},function(e,t,n){"use strict";var r=function(e){return e&&e.__esModule?e:{default:e}}(n(0));r.default.install("pc",function(){var e=this,t=r.default.util,n=e.controls,o=e.root,a=0,i=void 0,l="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",s="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",u=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),c=t.createDom("xg-enter",'',{},"xgplayer-enter"),p=c.querySelector(".xgplayer-enter-logo");o.appendChild(u),o.appendChild(c);var f=u.querySelector("path"),d=new Image;d.onload=function(){c.querySelector(".xgplayer-enter-tips").style.display="block"},e.config.enterLogo?(d.src=e.config.enterLogo,p.style.backgroundImage='url("'+e.config.enterLogo+'")'):d.src=t.getBgImage(p),["click","touchstart"].forEach(function(n){u.addEventListener(n,function(n){n.preventDefault(),n.stopPropagation(),e.config.url&&(t.hasClass(o,"xgplayer-nostart")?(t.removeClass(o,"xgplayer-nostart"),t.addClass(o,"xgplayer-is-enter"),o.querySelector("video")||e.start(),e.on("canplay",function(){t.removeClass(o,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(o,"xgplayer-is-enter")}),e.play(),setTimeout(function(){e.play()},10)):e.paused&&(t.removeClass(o,"xgplayer-nostart xgplayer-isloading"),setTimeout(function(){e.play()},10)))})}),u.addEventListener("animationend",function(e){e.preventDefault(),t.removeClass(u,"xgplayer-start-interact"),u.style.display="none"}),e.on("play",function(){f.setAttribute("d",l),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.on("pause",function(){f.setAttribute("d",s),u.style.display="inline-block",t.addClass(u,"xgplayer-start-interact")}),e.video.addEventListener("click",function(n){n.preventDefault(),n.stopPropagation(),document.activeElement===e.video?(a++,i&&clearTimeout(i),1===a?i=setTimeout(function(){if(t.hasClass(e.root,"xgplayer-nostart"))return!1;e.ended||(e.paused?e.play():e.pause()),a=0},200):a=0):e.video.focus()},!1),e.video.addEventListener("dblclick",function(t){if(t.preventDefault(),t.stopPropagation(),document.activeElement===e.video){var r=n.querySelector(".xgplayer-fullscreen");if(r){var o=void 0;document.createEvent?(o=document.createEvent("Event")).initEvent("click",!0,!0):o=new Event("click"),r.dispatchEvent(o)}}else e.video.focus()},!1),o.addEventListener("mouseenter",function(t){e.emit("focus",e)},!1),o.addEventListener("mouseleave",function(t){e.emit("blur",e)},!1),n.addEventListener("mouseenter",function(t){e.userTimer&&clearTimeout(e.userTimer)},!1),n.addEventListener("mouseleave",function(t){e.emit("focus",e)},!1)})},function(e,t,n){"use strict";var r=a(n(0)),o=a(n(2));function a(e){return e&&e.__esModule?e:{default:e}}r.default.install("mobile",function(){var e=this,t=r.default.util,n=e.root;e.config.autoplay=!1;var a=function(e){var t=r.default.util;return e.some(function(e){return"Function"===t.typeOf(e)?e.call(navigator.userAgent):"RegExp"===t.typeOf(e)?e.test(navigator.userAgent):"String"===t.typeOf(e)&&navigator.userAgent.indexOf(e)>-1})}(e.config.whitelist);e.mobilePass=a;var i="M576,363L810,512L576,661zM342,214L576,363L576,661L342,810z",l="M598,214h170v596h-170v-596zM256 810v-596h170v596h-170z",s=t.createDom("xg-start",'\n \n \n ',{},"xgplayer-start"),u=t.createDom("xg-enter",'',{},"xgplayer-enter"),c=u.querySelector(".xgplayer-enter-logo");n.appendChild(s),n.appendChild(u);var p=s.querySelector("path"),f=new Image,d=new o.default({from:l,to:i,progress:function(e,t){p.setAttribute("d",d.toSVGString(e))}});u.querySelector(".xgplayer-enter-tips").style.display="block",e.start(),a?(e.config.enterLogo?(f.src=e.config.enterLogo,c.style.backgroundImage='url("'+e.config.enterLogo+'")'):f.src=t.getBgImage(c),e.video.addEventListener("touchstart",function(t){t.preventDefault(),e.emit("focus")},!1),s.addEventListener("touchend",function(r){r.preventDefault(),t.hasClass(n,"xgplayer-nostart")?(t.removeClass(n,"xgplayer-nostart"),t.addClass(n,"xgplayer-is-enter"),e.on("canplay",function(){t.removeClass(n,"xgplayer-is-enter")}),e.once("playing",function(){t.removeClass(n,"xgplayer-is-enter")}),e.play()):e.paused?e.play():e.pause()}),e.on("play",function(){d.reset(l,i)}),e.on("pause",function(){d.reset(i,l)})):(t.addClass(n,"xgplayer-mobile-npassed"),e.once("ready",function(){e.video.controls=e.config.controls,e.video.controlsList=e.config.controlsList.join(" "),e.config.poster&&(e.video.poster=e.config.poster)})),e.config.debug&&function(e){var t={};Object.assign(t,{host:"127.0.0.1",port:9090},e);var n=document.createElement("script"),r=document.createElement("h4");r.style.cssText="position:fixed;bottom:0;padding:10px;width:100%;background-color:#fff;text-align:center",r.textContent="weinre --boundHost "+t.host+" --httpPort "+t.port+"\r\n 启动服务后,刷新页面",n.anonymous=!0,n.async=!0,n.src="http://"+t.host+":"+t.port+"/target/target-script-min.js#anonymous",n.onload=function(){r.parentNode.removeChild(r)},document.body.appendChild(n),document.body.appendChild(r)}(e.config.debug)})},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;ni.length){for(var c=function(e){i[e]={id:e,queue:[],step:t.channels[e].step,surplus:t.channels[e].surplus},t.channels[e].queue.forEach(function(t){return i[e].queue.push(t)})},p=0;pn.length)return{result:!1,message:"exceed channels.length, occupy="+o+",channelsSize="+n.length};for(var a=!0,i=void 0,l=-1,s=0,u=n.length;s-1&&(r.queue.splice(i,1),0===i&&(r.step=9999,r.surplus=0))}}},{key:"update",value:function(){var e=this.channels,t=this.width;e.forEach(function(e){var n=e.queue[0];n?e.surplus=t-n.left-n.width:(e.step=9999,e.surplus=0)})}},{key:"reset",value:function(){var e=this.player.root,t=this;setTimeout(function(){var n=e.querySelector(".xgplayer-bullet"),r=n.getBoundingClientRect();t.width=r.width,t.height=r.height,t.container=n;for(var o=/mobile/gi.test(navigator.userAgent)?10:12,a=Math.floor(t.height/o),i=[],l=0;l0?e.map(function(e){return{id:e.danmaku_id,txt:e.text.slice(0,40),duration:1*e.duration,color:e.text_color.replace("0x","#"),scale:1*e.text_scale,start:1*e.offset_time}}):[]}},n),t.on("dataIncoming",this.dataHandle.bind(this)),t.on("seeked",this.seekHandle.bind(this)),t.on("bullet_remove",this.updateQueue.bind(this)),t.on("ended",this.stop.bind(this)),t.on("pause",this.pause.bind(this)),t.on("play",this.play.bind(this))}return r(e,[{key:"updateQueue",value:function(e){var t=this;t.queue.some(function(n,r){if(n.id===e.bullet.id)return t.queue.splice(r,1),!0})}},{key:"init",value:function(){var e=this;if(e.data)return e.player.paused?void(e.status="paused"):e.player.ended?void(e.status="ended"):(e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),void e.player.emit("dataIncoming"));fetch(e.options.url,{method:e.options.method,headers:{Accept:"application/json"}}).then(function(t){t.ok&&t.json().then(function(t){var n=e.options.dataMap.call(null,t.data);if(n.length){e.data=n;var r=document.createElement("span");r.style.padding=e.options.padding+"||'0px'",r.style.position="absolute",r.style.left="-99999px",document.body.appendChild(r);var o=void 0;if(e.data.forEach(function(e){r.textContent=e.txt,r.style.fontSize=20*e.scale+"px",o=r.getBoundingClientRect(),e.width=o.width,e.height=o.height}),e.data.sort(function(e,t){return e.start-t.start}),document.body.removeChild(r),e.player.paused)return void(e.status="paused");if(e.player.ended)return void(e.status="ended");e.readData(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3),e.player.emit("dataIncoming")}})}).catch(function(e){console.log("Fetch错误:"+e)})}},{key:"start",value:function(){this.status="playing",this.channel.reset(),this.init()}},{key:"stop",value:function(){this.status="closed",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer),this.queue.length=0,this.container.innerHTML=""}},{key:"play",value:function(){var e=this,t=o.default.util;"idle"===e.status||"ended"===e.status?t.hasClass(e.container,"xgplayer-has-bullet")&&e.start():"paused"===e.status&&t.hasClass(e.container,"xgplayer-has-bullet")&&(e.status="playing",e.dataHandle(),e.retryTimer=setInterval(function(){e.readData(),e.dataHandle()},e.interval-1e3))}},{key:"pause",value:function(){"playing"===this.status?(this.status="paused",clearTimeout(this.retryTimer),(0,a.default)("cancel")(this.timer)):"ended"===this.status&&this.stop()}},{key:"dataHandle",value:function(){var e=(0,a.default)("cancel");if(e(this.timer),this.queue.length){this.queue.forEach(function(e){"waiting"!==e.status&&"start"!==e.status||(e.status="start",e.move())});var t=(0,a.default)("request");this.timer=t(this.dataHandle.bind(this))}else e(this.timer)}},{key:"readData",value:function(){var e=this,t=this.player,n=this.formatTime(t.currentTime),r=void 0,o=e.interval,a=e.channel,i=e.container,l=e.data.filter(function(e){return e.start<=n&&n<=e.start+o});l.length>0&&l.forEach(function(n){r=new c(t,i,n),a.addBullet(r).result&&(e.queue.push(r),r.reset(),r.attach())})}},{key:"seekHandle",value:function(){o.default.util;this.stop(),this.player.paused?this.status="idle":(this.status="playing",this.channel.resetWithCb(),this.init())}},{key:"formatTime",value:function(e){var t=Math.floor(e);return 1e3*t+(e-t)}}]),e}(),f=function(){function e(t,n){s(this,e);var r=this;this.player=t,this.el_=this.createEl(),this.onceFlag=!1;["click","touchstart"].forEach(function(e){r.el_.addEventListener(e,function(e){e.preventDefault(),e.stopPropagation(),r.onClick()},!1)}),this.main=new p(t,n),"on"===n.switch&&this.player.once("play",function(){r.onChange(!0)})}return r(e,[{key:"createEl",value:function(){return o.default.util.createDom("xg-bullet-btn",'',{},"xgplayer-bullet-btn "+("on"===this.player.config.bullet.switch?"xgplayer-bullet-btn-active":""))}},{key:"onClick",value:function(){var e=this,t=o.default.util;t.toggleClass(e.el_,"xgplayer-bullet-btn-active");var n=!!t.hasClass(e.el_,"xgplayer-bullet-btn-active");function r(){e.onceFlag=!1,e.main.channel.resetWithCb(e.onChange.bind(e))}n?e.player.paused||e.player.ended?this.onceFlag||(this.onceFlag=!0,this.player.once("play",r)):r():(this.player.off("play",r),this.onChange(n))}},{key:"onChange",value:function(e){var t=o.default.util,n=this.player.root.querySelector(".xgplayer-bullet");e?(t.addClass(n,"xgplayer-has-bullet"),this.main.start()):(t.removeClass(n,"xgplayer-has-bullet"),this.main.stop())}}]),e}();o.default.install("makeBullet",function(){var e=this,t=o.default.util;if(e.config.bullet){var n=t.createDom("xg-bullet","",{},"xgplayer-bullet");e.root.appendChild(n);var r=new f(e,e.config.bullet);["touchstart","click"].forEach(function(t){n.addEventListener(t,function(t){t.preventDefault(),t.stopPropagation(),e.paused?e.play():e.pause()},!1)}),e.controls.appendChild(r.el_)}})},function(e,t,n){"use strict";var r,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}; /** * request-frame - requestAnimationFrame & cancelAnimationFrame polyfill for optimal cross-browser development. * @version v1.5.3 diff --git a/packages/xgplayer/src/player.js b/packages/xgplayer/src/player.js index 933285817..3d2723898 100755 --- a/packages/xgplayer/src/player.js +++ b/packages/xgplayer/src/player.js @@ -111,25 +111,38 @@ class Player extends Proxy { destroy () { let parentNode = this.root.parentNode + this.ev.forEach((item) => { + let evName = Object.keys(item)[0] + let evFunc = this[item[evName]] + if (evFunc) { + this.off(evName, evFunc) + } + }); + ['focus', 'blur'].forEach(item => { + this.off(item, this['on' + item.charAt(0).toUpperCase() + item.slice(1)]) + }) if (!this.paused) { this.pause() this.once('pause', () => { this.emit('destroy') parentNode.removeChild(this.root) parentNode.appendChild(this.rootBackup) + for (let k in this) { + if (k !== 'config') { + delete this[k] + } + } }) } else { this.emit('destroy') parentNode.removeChild(this.root) parentNode.appendChild(this.rootBackup) - } - setTimeout(function () { for (let k in this) { if (k !== 'config') { delete this[k] } } - }, 200) + } } replay () {