*{@linkhttps://github.com/muaz-khan/RecordRTC|RecordRTC} is a WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
functionr(e,t){if(!e)throw"First parameter is required.";t=newa(e,t=t||{type:"video"});varo=this;functioni(o){o&&(t.initCallback=function(){o(),o=t.initCallback=null});vari=newd(e,t);(f=newi(e,t)).record(),l("recording"),t.disableLogs||console.log("Initialized recorderType:",f.constructor.name,"for output-type:",t.type)}functionn(e){if(e=e||function(){},f){if("paused"===o.state)returno.resumeRecording(),voidsetTimeout((function(){n(e)}),1);"recording"===o.state||t.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',o.state),t.disableLogs||console.log("Stopped recording "+t.type+" stream."),"gif"!==t.type?f.stop(i):(f.stop(),i()),l("stopped")}elseg();functioni(i){if(f){Object.keys(f).forEach((function(e){"function"!=typeoff[e]&&(o[e]=f[e])}));varn=f.blob;if(!n){if(!i)throw"Recording failed.";f.blob=n=i}if(n&&!t.disableLogs&&console.log(n.type,"->",R(n.size)),e){varr;try{r=m.createObjectURL(n)}catch(e){}"function"==typeofe.call?e.call(o,r):e(r)}t.autoWriteToDisk&&c((function(e){varo={};o[t.type+"Blob"]=e,O.Store(o)}))}else"function"==typeofe.call?e.call(o,""):e("")}}functions(e){postMessage((newFileReaderSync).readAsDataURL(e))}functionc(e,o){if(!e)throw"Pass a callback function over getDataURL.";vari=o?o.blob:(f||{}).blob;if(!i)returnt.disableLogs||console.warn("Blob encoder did not finish its job yet."),voidsetTimeout((function(){c(e,o)}),1e3);if("undefined"==typeofWorker||navigator.mozGetUserMedia){varn=newFileReader;n.readAsDataURL(i),n.onload=function(t){e(t.target.result)}}else{varr=function(e){try{vart=m.createObjectURL(newBlob([e.toString(),"this.onmessage = function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),o=newWorker(t);returnm.revokeObjectURL(t),o}catch(e){}}(s);r.onmessage=function(t){e(t.data)},r.postMessage(i)}}functionu(e){e=e||0,"paused"!==o.state?"stopped"!==o.state&&(e>=o.recordingDuration?n(o.onRecordingStopped):(e+=1e3,setTimeout((function(){u(e)}),1e3))):setTimeout((function(){u(e)}),1e3)}functionl(e){o&&(o.state=e,"function"==typeofo.onStateChanged.call?o.onStateChanged.call(o,e):o.onStateChanged(e))}varf,h='It seems that recorder is destroyed or "startRecording" is not invoked for '+t.type+" recorder.";functiong(){!0!==t.disableLogs&&console.warn(h)}varp={startRecording:function(n){returnt.disableLogs||console.log("RecordRTC version: ",o.version),n&&(t=newa(e,n)),t.disableLogs||console.log("started recording "+t.type+" stream."),f?(f.clearRecordedData(),f.record(),l("recording"),o.recordingDuration&&u(),o):(i((function(){o.recordingDuration&&u()})),o)},stopRecording:n,pauseRecording:function(){f?"recording"===o.state?(l("paused"),f.pause(),t.disableLogs||console.log("Paused recording.")):t.disableLogs||console.warn("Unable to pause the recording. Recording state: ",o.state):g()},resumeRecording:function(){f?"paused"===o.state?(l("recording"),f.resume(),t.disableLogs||console.log("Resumed recording.")):t.disableLogs||console.warn("Unable to resume the recording. Recording state: ",o.state):g()},initRecorder:i,setRecordingDuration:function(e,t){if(void0===e)throw"recordingDuration is required.";if("number"!=typeofe)throw"recordingDuration must be a number.";returno.recordingDuration=e,o.onRecordingStopped=t||function(){},{onRecordingStopped:function(e){o.onRecordingStopped=e}}},clearRecordedData:function(){f?(f.clearRecordedData(),t.disableLogs||console.log("Cleared old recorded data.")):g()},getBlob:function(){if(f)returnf.blob;g()},getDataURL:c,toURL:function(){if(f)returnm.createObjectURL(f.blob);g()},getInternalRecorder:function(){returnf},save:function(e){f?S(f.blob,e):g()},getFromDisk:function(e){f?r.getFromDisk(t.type,e):g()},setAdvertisementArray:function(e){t.advertisement=[];for(varo=e.length,i=0;i<o;i++)t.advertisement.push({duration:i,image:e[i]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){"recording"!==o.state||t.disableLogs||console.warn("Stop an active recorder."),f&&"function"==typeoff.clearRecordedData&&f.clearRecordedData(),f=null,l("inactive"),o
*MediaStreamRecorderisanabstractionlayerfor{@linkhttps://w3c.github.io/mediacapture-record/MediaRecorder.html|MediaRecorder API}. It is used by {@link RecordRTC} to record MediaStream(s) in both Chrome and Firefox.
functionD(e,t){if(!k(e,"audio").length)throw"Your stream has no audio tracks.";varo,i=this,n=[],a=[],d=!1,s=0,c=2,u=(t=t||{}).desiredSampRate;functionl(){if(!1===t.checkForInactiveTracks)return!0;if("active"ine){if(!e.active)return!1}elseif("ended"ine&&e.ended)return!1;return!0}functionf(e,t){functiono(e,t){varo,i=e.numberOfAudioChannels,n=e.leftBuffers.slice(0),r=e.rightBuffers.slice(0),a=e.sampleRate,d=e.internalInterleavedLength,s=e.desiredSampRate;functionc(e,t,o){vari=Math.round(e.length*(t/o)),n=[],r=Number((e.length-1)/(i-1));n[0]=e[0];for(vara=1;a<i-1;a++){vard=a*r,s=Number(Math.floor(d)).toFixed(),c=Number(Math.ceil(d)).toFixed(),l=d-s;n[a]=u(e[s],e[c],l)}returnn[i-1]=e[e.length-1],n}functionu(e,t,o){returne+(t-e)*o}functionl(e,t){for(varo=newFloat64Array(t),i=0,n=e.length,r=0;r<n;r++){vara=e[r];o.set(a,i),i+=a.length}returno}functionf(e,t,o){for(vari=o.length,n=0;n<i;n++)e.setUint8(t+n,o.charCodeAt(n))}2===i&&(n=l(n,d),r=l(r,d),s&&(n=c(n,s,a),r=c(r,s,a))),1===i&&(n=l(n,d),s&&(n=c(n,s,a))),s&&(a=s),2===i&&(o=function(e,t){for(varo=e.length+t.length,i=newFloat64Array(o),n=0,r=0;r<o;)i[r++]=e[n],i[r++]=t[n],n++;returni}(n,r)),1===i&&(o=n);varh=o.length,m=newArrayBuffer(44+2*h),g=newDataView(m);f(g,0,"RIFF"),g.setUint32(4,36+2*h,!0),f(g,8,"WAVE"),f(g,12,"fmt "),g.setUint32(16,16,!0),g.setUint16(20,1,!0),g.setUint16(22,i,!0),g.setUint32(24,a,!0),g.setUint32(28,2*a,!0),g.setUint16(32,2*i,!0),g.setUint16(34,16,!0),f(g,36,"data"),g.setUint32(40,2*h,!0);for(varp=h,v=44,b=0;b<p;b++)g.setInt16(v,32767*o[b],!0),v+=2;if(t)returnt({buffer:m,view:g});postMessage({buffer:m,view:g})}if(e.noWorker)o(e,(function(e){t(e.buffer,e.view)}));else{vari,n,r,a=(i=o,n=m.createObjectURL(newBlob([i.toString(),";this.onmessage = function (eee) {"+i.name+"(eee.data);}"],{type:"application/javascript"})),(r=newWorker(n)).workerURL=n,r);a.onmessage=function(e){t(e.data.buffer,e.data.view),m.revokeObjectURL(a.workerURL),a.terminate()},a.postMessage(e)}}!0===t.leftChannel&&(c=1),1===t.numberOfAudioChannels&&(c=1),(!c||c<1)&&(c=2),t.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+c),void0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!0),this.record=function(){if(!1===l())throw"Please make sure MediaStream is active.";y(),S=w=!1,d=!0,void0!==t.timeSlice&&C()},this.stop=function(e){e=e||function(){},d=!1,f({desiredSampRate:u,sampleRate:b,numberOfAudioChannels:c,internalInterleavedLength:s,leftBuffers:n,rightBuffers:1===c?[]:a,noWorker:t.noWorker},(function(t,o){i.blob=newBlob([o],{type:"audio/wav"}),i.buffer=newArrayBuffer(o.buffer.byteLength),i.view=o,i.sampleRate=u||b,i.bufferSize=v,i.length=s,S=!1,e&&e(i.blob)}))},void0===r.Storage&&(r.Storage={AudioContextConstructor:null,AudioContext:window.AudioContext||window.webkitAudioContext}),r.Storage.AudioContextConstructor&&"closed"!==r.Storage.AudioContextConstructor.state||(r.Storage.AudioContextConstructor=newr.Storage.AudioContext);varh=r.Storage.AudioContextConstructor,g=h.createMediaStreamSource(e),p=[0,256,512,1024,2048,4096,8192,16384],v=void0===t.bufferSize?4096:t.bufferSize;if(-1===p.indexOf(v)&&(t.disableLogs||console.log("Legal values for buffer-size are "+JSON.stringify(p,null,"\t"))),h.createJavaScriptNode)o=h.createJavaScriptNode(v,c,c);else{if(!h.createScriptProcessor)throw"WebAudio API has no support on this browser.";o=h.createScriptProcessor(v,c,c)}g.connect(o),t.bufferSize||(v=o.bufferSize);varb=void0!==t.sampleRate?t.sampleRate:h.sampleRate||44100;(b<22050||b>96e3)&&(t.disableLogs||console.log("sample-rate must be under range 22050 and 96000.")),t.disableLogs||t.desiredSampRate&&console.log("Desired sample-rate: "+t.desiredSampRate);varw=!1;functiony(){n=[],a=[],s=0,S=!1,d=!1,w=!1,h=null,i.leftchannel=n,i.rightchannel=a,i.numberOfAudioChannels=c,i.desiredSampRate=u,i.sampleRate=b,i.recordingLength=s,T={left:[],right:[],recordingLength:0}}functionR(){o&&(o.onaudioprocess=null,o.disconnect(),o=null),g&&(g.disconnect(),g=null),y()}this.pause=function(){w=!0},this.resume=function(){if(!1===l(
functionx(e,t){if("undefined"==typeofhtml2canvas)throw"Please link: https://www.webrtc-experiment.com/screenshot.js";(t=t||{}).frameInterval||(t.frameInterval=10);varo=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach((function(e){eindocument.createElement("canvas")&&(o=!0)}));vari,n,r,a=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),d=50,s=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(a&&s&&s[2]&&(d=parseInt(s[2],10)),a&&d<52&&(o=!1),t.useWhammyRecorder&&(o=!1),o)if(t.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),einstanceofHTMLCanvasElement)i=e;else{if(!(einstanceofCanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";i=e.canvas}elsenavigator.mozGetUserMedia&&(t.disableLogs||console.error("Canvas recording is NOT supported in Firefox."));this.record=function(){if(r=!0,o&&!t.useWhammyRecorder){vare;"captureStream"ini?e=i.captureStream(25):"mozCaptureStream"ini?e=i.mozCaptureStream(25):"webkitCaptureStream"ini&&(e=i.webkitCaptureStream(25));try{vara=newy;a.addTrack(k(e,"video")[0]),e=a}catch(e){}if(!e)throw"captureStream API are NOT available.";(n=newA(e,{mimeType:t.mimeType||"video/webm"})).record()}elseh.frames=[],f=(newDate).getTime(),l();t.initCallback&&t.initCallback()},this.getWebPImages=function(o){if("canvas"===e.nodeName.toLowerCase()){vari=h.frames.length;h.frames.forEach((function(e,o){varn=i-o;t.disableLogs||console.log(n+"/"+i+" frames remaining"),t.onEncodingCallback&&t.onEncodingCallback(n,i);varr=e.image.toDataURL("image/webp",1);h.frames[o].image=r})),t.disableLogs||console.log("Generating WebM"),o()}elseo()},this.stop=function(e){r=!1;vari=this;o&&n?n.stop(e):this.getWebPImages((function(){h.compile((function(o){t.disableLogs||console.log("Recording finished!"),i.blob=o,i.blob.forEach&&(i.blob=newBlob([],{type:"video/webm"})),e&&e(i.blob),h.frames=[]}))}))};varc=!1;functionu(){h.frames=[],r=!1,c=!1}functionl(){if(c)returnf=(newDate).getTime(),setTimeout(l,500);if("canvas"===e.nodeName.toLowerCase()){varo=(newDate).getTime()-f;returnf=(newDate).getTime(),h.frames.push({image:(i=document.createElement("canvas"),n=i.getContext("2d"),i.width=e.width,i.height=e.height,n.drawImage(e,0,0),i),duration:o}),void(r&&setTimeout(l,t.frameInterval))}vari,n;html2canvas(e,{grabMouse:void0===t.showMousePointer||t.showMousePointer,onrendered:function(e){varo=(newDate).getTime()-f;if(!o)returnsetTimeout(l,t.frameInterval);f=(newDate).getTime(),h.frames.push({image:e.toDataURL("image/webp",1),duration:o}),r&&setTimeout(l,t.frameInterval)}})}this.pause=function(){c=!0,ninstanceofA&&n.pause()},this.resume=function(){c=!1,ninstanceofA?n.resume():r||this.record()},this.clearRecordedData=function(){r&&this.stop(u),u()},this.name="CanvasRecorder",this.toString=function(){returnthis.name};varf=(newDate).getTime(),h=newB.Video(100)}
varB=function(){functione(e){this.frames=[],this.duration=e||1,this.quality=.8}functiont(e){functiont(e,t,o){return[{data:e,id:231}].concat(o.map((function(e){varo=function(e){vart=0;e.keyframe&&(t|=128);e.invisible&&(t|=8);e.lacing&&(t|=e.lacing<<1);e.discardable&&(t|=1);if(e.trackNum>127)throw"TrackNumber > 127 not supported";return[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map((function(e){returnString.fromCharCode(e)})).join("")+e.frame}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(t)});returnt+=e.duration,{data:o,id:163}})))}functiono(e){for(vart=[];e>0;)t.push(255&e),e>>=8;returnnewUint8Array(t.reverse())}functioni(e){returnnewUint8Array(e.split("").map((function(e){returne.charCodeAt(0)})))}functionn(e){vart=[];e=(e.length%8?newArray(9-e.length%8).join("0"):"")+e;for(varo=0;o<e.length;o+=8)t.push(parseInt(e.substr(o,8),2));returnnewUint8Array(t)}functionr(e,t){returnparseInt(e.substr(t+4,4).split("").map((function(e){vart=e.charCodeAt(0).toString(2);returnnewArray(8-t.length+1).join("0")+t})).join(""),2)}vara=newfunction(e){varr=function(e){if(!e[0])returnvoidpostMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."});for(vart=e[0].width,o=e[0].height,i=e[0].duration,n=1;n<e.length;n++)i+=e[n].duration;return{duration:i,width:t,height:o}}(e);if(!r)return[];for(vara,d=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:(a=r.duration,[].slice.call(newUint8Array(newFloat64Array([a]).buffer),0).map((function(e){returnString.fromCharCode(e)})).reverse().join("")),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:29637},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:r.width,id:176},{data:r.height,id:186}]}]}]}]}],s=0,c=0;s<e.length;){varu=[],l=0;do{u.push(e[s]),l+=e[s].duration,s++}while(s<e.length&&l<3e4);varf={id:524531317,data:t(c,0,u)};d[1].data.push(f),c+=l}returnfunctione(t){for(varr=[],a=0;a<t.length;a++){vard=t[a].data;"object"==typeofd&&(d=e(d)),"number"==typeofd&&(d=n(d.toString(2))),"string"==typeofd&&(d=i(d));vars=d.size||d.byteLength||d.length,c=Math.ceil(Math.ceil(Math.log(s)/Math.log(2))/8),u=s.toString(2),l=newArray(7*c+7+1-u.length).join("0")+u,f=newArray(c).join("0")+"1"+l;r.push(o(t[a].id)),r.push(n(f)),r.push(d)}returnnewBlob(r,{type:"video/webm"})}(d)}(e.map((function(e){vart=function(e){for(vart=e.RIFF[0].WEBP[0],o=t.indexOf("*"),i=0,n=[];i<4;i++)n[i]=t.charCodeAt(o+3+i);return{width:16383&(n[1]<<8|n[0]),height:16383&(n[3]<<8|n[2]),data:t,riff:e}}(functione(t){for(varo=0,i={};o<t.length;){varn=t.substr(o,4),a=r(t,o),d=t.substr(o+4+4,a);o+=8+a,i[n]=i[n]||[],"RIFF"===n||"LIST"===n?i[n].push(e(d)):i[n].push(d)}returni}(atob(e.image.slice(23))));returnt.duration=e.duration,t})));postMessage(a)}returne.prototype.add=function(e,t){if("canvas"ine&&(e=e.canvas),"toDataURL"ine&&(e=e.toDataURL("image/webp",this.quality)),!/^data:image\/webp;base64,/gi.test(e))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:e,duration:t||this.duration})},e.prototype.compile=function(e){varo,i,n,r=(o=t,i=m.createObjectURL(newBlob([o.toString(),"this.onmessage = function (eee) {"+o.name+"(eee.data);}"],{type:"application/javascript"})),n=newWorker(i),m.revokeObjectURL(i),n);r.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data)},r.postMessage(this.frames)},{Video:e}}();void0!==r&&(r.Whammy=B);
*/var O={init:function(){var e=this;if("undefined"!=typeof indexedDB&&void 0!==indexedDB.open){var t,o=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),i=indexedDB.open(o,1);i.onerror=e.onError,i.onsuccess=function(){((t=i.result).onerror=e.onError,t.setVersion)?1!==t.version?t.setVersion(1).onsuccess=function(){n(t),r()}:r():r()},i.onupgradeneeded=function(e){n(e.target.result)}}elseconsole.error("IndexedDB API are not available in this browser.");functionn(t){t.createObjectStore(e.dataStoreName)}functionr(){varo=t.transaction([e.dataStoreName],"readwrite");functioni(t){o.objectStore(e.dataStoreName).get(t).onsuccess=function(o){e.callback&&e.callback(o.target.result,t)}}e.videoBlob&&o.objectStore(e.dataStoreName).put(e.videoBlob,"videoBlob"),e.gifBlob&&o.objectStore(e.dataStoreName).put(e.gifBlob,"gifBlob"),e.audioBlob&&o.objectStore(e.dataStoreName).put(e.audioBlob,"audioBlob"),i("audioBlob"),i("videoBlob"),i("gifBlob")}},Fetch:function(e){returnthis.callback=e,this.init(),this},Store:function(e){returnthis.audioBlob=e.audioBlob,this.videoBlob=e.videoBlob,this.gifBlob=e.gifBlob,this.init(),this},onError:function(e){console.error(JSON.stringify(e,null,"\t"))},dataStoreName:"recordRTC",dbName:null};
functionF(e,t){e=e||[];varo,i,n=this;(t=t||{elementClass:"multi-streams-mixer",mimeType:"video/webm",video:{width:360,height:240}}).frameInterval||(t.frameInterval=10),t.video||(t.video={}),t.video.width||(t.video.width=360),t.video.height||(t.video.height=240),this.record=function(){varn;o=newI(e,t.elementClass||"multi-streams-mixer"),(n=[],e.forEach((function(e){k(e,"video").forEach((function(e){n.push(e)}))})),n).length&&(o.frameInterval=t.frameInterval||10,o.width=t.video.width||360,o.height=t.video.height||240,o.startDrawingFrames()),t.previewStream&&"function"==typeoft.previewStream&&t.previewStream(o.getMixedStream()),(i=newA(o.getMixedStream(),t)).record()},this.stop=function(e){i&&i.stop((function(t){n.blob=t,e(t),n.clearRecordedData()}))},this.pause=function(){i&&i.pause()},this.resume=function(){i&&i.resume()},this.clearRecordedData=function(){i&&(i.clearRecordedData(),i=null),o&&(o.releaseStreams(),o=null)},this.addStreams=function(n){if(!n)throw"First parameter is required.";ninstanceofArray||(n=[n]),e.concat(n),i&&o&&(o.appendStreams(n),t.previewStream&&"function"==typeoft.previewStream&&t.previewStream(o.getMixedStream()))},this.resetVideoStreams=function(e){o&&(!e||einstanceofArray||(e=[e]),o.resetVideoStreams(e))},this.getMixer=function(){returno},this.name="MultiStreamRecorder",this.toString=function(){returnthis.name}}
functionj(e,t){varo,i,n;functionr(){returnnewReadableStream({start:function(i){varn=document.createElement("canvas"),r=document.createElement("video"),a=!0;r.srcObject=e,r.muted=!0,r.height=t.height,r.width=t.width,r.volume=0,r.onplaying=function(){n.width=t.width,n.height=t.height;vare=n.getContext("2d"),d=1e3/t.frameRate,s=setInterval((function(){if(o&&(clearInterval(s),i.close()),a&&(a=!1,t.onVideoProcessStarted&&t.onVideoProcessStarted()),e.drawImage(r,0,0),"closed"!==i._controlledReadableStream.state)try{i.enqueue(e.getImageData(0,0,t.width,t.height))}catch(e){}}),d)},r.play()}})}"undefined"!=typeofReadableStream&&"undefined"!=typeofWritableStream||console.error("Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"),(t=t||{}).width=t.width||640,t.height=t.height||480,t.frameRate=t.frameRate||30,t.bitrate=t.bitrate||1200,t.realtime=t.realtime||!0,this.record=function(){a=[],n=!1,this.blob=null,functione(d,s){if(!t.workerPath&&!s)returno=!1,voidfetch("https://unpkg.com/webm-wasm@latest/dist/webm-worker.js").then((function(t){t.arrayBuffer().then((function(t){e(d,t)}))}));if(!t.workerPath&&sinstanceofArrayBuffer){varc=newBlob([s],{type:"text/javascript"});t.workerPath=m.createObjectURL(c)}t.workerPath||console.error("workerPath parameter is missing."),(i=newWorker(t.workerPath)).postMessage(t.webAssemblyPath||"https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm"),i.addEventListener("message",(function(e){"READY"===e.data?(i.postMessage({width:t.width,height:t.height,bitrate:t.bitrate||1200,timebaseDen:t.frameRate||30,realtime:t.realtime}),r().pipeTo(newWritableStream({write:function(e){o?console.error("Got image, but recorder is finished!"):i.postMessage(e.data.buffer,[e.data.buffer])}}))):e.data&&(n||a.push(e.data))}))}(e),"function"==typeoft.initCallback&&t.initCallback()},this.pause=function(){n=!0},this.resume=function(){n=!1};vara=[];this.stop=function(e){o=!0;vart=this;!function(e){i?(i.addEventListener("message",(function(t){null===t.data&&(i.terminate(),i=null,e&&e())})),i.postMessage(null)):e&&e()}((function(){t.blob=newBlob(a,{type:"video/webm"}),e(t.blob)}))},this.name="WebAssemblyRecorder",this.toString=function(){returnthis.name},this.clearRecordedData=function(){a=[],n=!1,this.blob=null},this.blob=null}void0!==r&&(r.DiskStorage=O),void0!==r&&(r.GifRecorder=E),void0===r&&(e.exports=I,void0===(n=function(){returnI}.apply(t,[]))||(e.exports=n)),void0!==r&&(r.MultiStreamRecorder=F),void0!==r&&(r.RecordRTCPromisesHandler=
function(e,t){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void0===e)throw'First argument "MediaStream" is required.';varo=this;o.recordRTC=newr(e,t),this.startRecording=function(){returnnewPromise((function(e,t){try{o.recordRTC.startRecording(),e()}catch(e){t(e)}}))},this.stopRecording=function(){returnnewPromise((function(e,t){try{o.recordRTC.stopRecording((function(i){o.blob=o.recordRTC.getBlob(),o.blob&&o.blob.size?e(i):t("Empty blob.",o.blob)}))}catch(e){t(e)}}))},this.pauseRecording=function(){returnnewPromise((function(e,t){try{o.recordRTC.pauseRecording(),e()}catch(e){t(e)}}))},this.resumeRecording=function(){returnnewPromise((function(e,t){try{o.recordRTC.resumeRecording(),e()}catch(e){t(e)}}))},this.getDataURL=function(e){returnnewPromise((function(e,t){try{o.recordRTC.getDataURL((function(t){e(t)}))}catch(e){t(e)}}))},this.getBlob=function(){returnnewPromise((function(e,t){try{e(o.recordRTC.getBlob())}catch(e){t(e)}}))},this.getInternalRecorder=function(){returnnewPromise((function(e,t){try{e(o.recordRTC.getInternalRecorder())}catch(e){t(e)}}))},this.reset=function(){returnnewPromise((function(e,t){try{e(o.recordRTC.reset())}catch(e){t(e)}}))},this.destroy=function(){returnnewPromise((function(e,t){try{e(o.recordRTC.destroy())}catch(e){t(e)}}))},this.getState=function(){returnnewPromise((function(e,t){try{e(o.recordRTC.getState())}catch(e){t(e)}}))},this.blob=null,this.version="5.6.1"}),void0!==r&&(r.WebAssemblyRecorder=j)}).call(this,o(1),o(2))},function(e,t){varo;o=function(){returnthis}();try{o=o||newFunction("return this")()}catch(e){"object"==typeofwindow&&(o=window)}e.exports=o},function(e,t){varo,i,n=e.exports={};functionr(){thrownewError("setTimeout has not been defined")}functiona(){thrownewError("clearTimeout has not been defined")}functiond(e){if(o===setTimeout)returnsetTimeout(e,0);if((o===r||!o)&&setTimeout)returno=setTimeout,setTimeout(e,0);try{returno(e,0)}catch(t){try{returno.call(null,e,0)}catch(t){returno.call(this,e,0)}}}!function(){try{o="function"==typeofsetTimeout?setTimeout:r}catch(e){o=r}try{i="function"==typeofclearTimeout?clearTimeout:a}catch(e){i=a}}();vars,c=[],u=!1,l=-1;functionf(){u&&s&&(u=!1,s.length?c=s.concat(c):l=-1,c.length&&h())}functionh(){if(!u){vare=d(f);u=!0;for(vart=c.length;t;){for(s=c,c=[];++l<t;)s&&s[l].run();l=-1,t=c.length}s=null,u=!1,function(e){if(i===clearTimeout)returnclearTimeout(e);if((i===a||!i)&&clearTimeout)returni=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{returni.call(null,e)}catch(t){returni.call(this,e)}}}(e)}}functionm(e,t){this.fun=e,this.array=t}functiong(){}n.nextTick=function(e){vart=newArray(arguments.length-1);if(arguments.length>1)for(varo=1;o<arguments.length;o++)t[o-1]=arguments[o];c.push(newm(e,t)),1!==c.length||u||d(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=g,n.addListener=g,n.once=g,n.off=g,n.removeListener=g,n.removeAllListeners=g,n.emit=g,n.prependListener=g,n.prependOnceListener=g,n.listeners=function(e){return[]},n.binding=function(e){thrownewError("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){thrownewError("process.chdir is not supported")},n.umask=function(){return0}}])}));