-
Notifications
You must be signed in to change notification settings - Fork 29
/
polyfill.js
1 lines (1 loc) · 3.51 KB
/
polyfill.js
1
!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},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=2)}([function(e,t,n){var i,r=window.AudioContext||window.webkitAudioContext;function a(e){this.stream=e,this.state="inactive",this.em=document.createDocumentFragment(),this.encoder=function(e){var t=e.toString().replace(/^function\s*\(\)\s*{/,"").replace(/}$/,""),n=new Blob([t]);return new Worker(URL.createObjectURL(n))}(a.encoder);var t=this;this.encoder.addEventListener("message",function(e){var n=new Event("dataavailable");n.data=new Blob([e.data],{type:t.mimeType}),t.em.dispatchEvent(n),"inactive"===t.state&&t.em.dispatchEvent(new Event("stop"))})}a.prototype={mimeType:"audio/wav",start:function(e){if("inactive"===this.state){this.state="recording",i||(i=new r);var t=i.createMediaStreamSource(this.stream),n=i.createScriptProcessor(2048,1,1),a=this;n.onaudioprocess=function(e){"recording"===a.state&&a.encoder.postMessage(["encode",e.inputBuffer.getChannelData(0)])},t.connect(n),n.connect(i.destination),this.em.dispatchEvent(new Event("start")),e&&(this.slicing=setInterval(function(){"recording"===a.state&&a.requestData()},e))}},stop:function(){"inactive"!==this.state&&(this.requestData(),this.state="inactive",clearInterval(this.slicing))},pause:function(){"recording"===this.state&&(this.state="paused",this.em.dispatchEvent(new Event("pause")))},resume:function(){"paused"===this.state&&(this.state="recording",this.em.dispatchEvent(new Event("resume")))},requestData:function(){"inactive"!==this.state&&this.encoder.postMessage(["dump",i.sampleRate])},addEventListener:function(){this.em.addEventListener.apply(this.em,arguments)},removeEventListener:function(){this.em.removeEventListener.apply(this.em,arguments)},dispatchEvent:function(){this.em.dispatchEvent.apply(this.em,arguments)}},a.isTypeSupported=function(e){return/audio\/wave?/.test(e)},a.notSupported=!navigator.mediaDevices||!r,a.encoder=n(3),e.exports=a},,function(e,t,n){"use strict";n.r(t);var i=n(0),r=n.n(i);window.MediaRecorder=r.a},function(e,t){e.exports=function(){var e=2,t=[];onmessage=function(n){"encode"===n.data[0]?function(n){for(var i=n.length,r=new Uint8Array(i*e),a=0;a<i;a++){var s=a*e,o=n[a];o>1?o=1:o<-1&&(o=-1),o*=32768,r[s]=o,r[s+1]=o>>8}t.push(r)}(n.data[1]):function(n){var i=t.length?t[0].length:0,r=t.length*i,a=new Uint8Array(44+r),s=new DataView(a.buffer);s.setUint32(0,1380533830,!1),s.setUint32(4,36+r,!0),s.setUint32(8,1463899717,!1),s.setUint32(12,1718449184,!1),s.setUint32(16,16,!0),s.setUint16(20,1,!0),s.setUint16(22,1,!0),s.setUint32(24,n,!0),s.setUint32(28,n*e,!0),s.setUint16(32,e,!0),s.setUint16(34,8*e,!0),s.setUint32(36,1684108385,!1),s.setUint32(40,r,!0);for(var o=0;o<t.length;o++)a.set(t[o],o*i+44);t=[],postMessage(a.buffer,[a.buffer])}(n.data[1])}}}]);