memoplay-screen-recorder
Version:
A simple screen recorder
2 lines • 34.6 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{13:function(e,t,n){var a;a=function(){var e={172351395:{name:"EBML",type:"Container"},646:{name:"EBMLVersion",type:"Uint"},759:{name:"EBMLReadVersion",type:"Uint"},754:{name:"EBMLMaxIDLength",type:"Uint"},755:{name:"EBMLMaxSizeLength",type:"Uint"},642:{name:"DocType",type:"String"},647:{name:"DocTypeVersion",type:"Uint"},645:{name:"DocTypeReadVersion",type:"Uint"},108:{name:"Void",type:"Binary"},63:{name:"CRC-32",type:"Binary"},190023271:{name:"SignatureSlot",type:"Container"},16010:{name:"SignatureAlgo",type:"Uint"},16026:{name:"SignatureHash",type:"Uint"},16037:{name:"SignaturePublicKey",type:"Binary"},16053:{name:"Signature",type:"Binary"},15963:{name:"SignatureElements",type:"Container"},15995:{name:"SignatureElementList",type:"Container"},9522:{name:"SignedElement",type:"Binary"},139690087:{name:"Segment",type:"Container"},21863284:{name:"SeekHead",type:"Container"},3515:{name:"Seek",type:"Container"},5035:{name:"SeekID",type:"Binary"},5036:{name:"SeekPosition",type:"Uint"},88713574:{name:"Info",type:"Container"},13220:{name:"SegmentUID",type:"Binary"},13188:{name:"SegmentFilename",type:"String"},1882403:{name:"PrevUID",type:"Binary"},1868715:{name:"PrevFilename",type:"String"},2013475:{name:"NextUID",type:"Binary"},1999803:{name:"NextFilename",type:"String"},1092:{name:"SegmentFamily",type:"Binary"},10532:{name:"ChapterTranslate",type:"Container"},10748:{name:"ChapterTranslateEditionUID",type:"Uint"},10687:{name:"ChapterTranslateCodec",type:"Uint"},10661:{name:"ChapterTranslateID",type:"Binary"},710577:{name:"TimecodeScale",type:"Uint"},1161:{name:"Duration",type:"Float"},1121:{name:"DateUTC",type:"Date"},15273:{name:"Title",type:"String"},3456:{name:"MuxingApp",type:"String"},5953:{name:"WritingApp",type:"String"},103:{name:"Timecode",type:"Uint"},6228:{name:"SilentTracks",type:"Container"},6359:{name:"SilentTrackNumber",type:"Uint"},39:{name:"Position",type:"Uint"},43:{name:"PrevSize",type:"Uint"},35:{name:"SimpleBlock",type:"Binary"},32:{name:"BlockGroup",type:"Container"},33:{name:"Block",type:"Binary"},34:{name:"BlockVirtual",type:"Binary"},13729:{name:"BlockAdditions",type:"Container"},38:{name:"BlockMore",type:"Container"},110:{name:"BlockAddID",type:"Uint"},37:{name:"BlockAdditional",type:"Binary"},27:{name:"BlockDuration",type:"Uint"},122:{name:"ReferencePriority",type:"Uint"},123:{name:"ReferenceBlock",type:"Int"},125:{name:"ReferenceVirtual",type:"Int"},36:{name:"CodecState",type:"Binary"},13730:{name:"DiscardPadding",type:"Int"},14:{name:"Slices",type:"Container"},104:{name:"TimeSlice",type:"Container"},76:{name:"LaceNumber",type:"Uint"},77:{name:"FrameNumber",type:"Uint"},75:{name:"BlockAdditionID",type:"Uint"},78:{name:"Delay",type:"Uint"},79:{name:"SliceDuration",type:"Uint"},72:{name:"ReferenceFrame",type:"Container"},73:{name:"ReferenceOffset",type:"Uint"},74:{name:"ReferenceTimeCode",type:"Uint"},47:{name:"EncryptedBlock",type:"Binary"},106212971:{name:"Tracks",type:"Container"},46:{name:"TrackEntry",type:"Container"},87:{name:"TrackNumber",type:"Uint"},13253:{name:"TrackUID",type:"Uint"},3:{name:"TrackType",type:"Uint"},57:{name:"FlagEnabled",type:"Uint"},8:{name:"FlagDefault",type:"Uint"},5546:{name:"FlagForced",type:"Uint"},28:{name:"FlagLacing",type:"Uint"},11751:{name:"MinCache",type:"Uint"},11768:{name:"MaxCache",type:"Uint"},254851:{name:"DefaultDuration",type:"Uint"},216698:{name:"DefaultDecodedFieldDuration",type:"Uint"},209231:{name:"TrackTimecodeScale",type:"Float"},4991:{name:"TrackOffset",type:"Int"},5614:{name:"MaxBlockAdditionID",type:"Uint"},4974:{name:"Name",type:"String"},177564:{name:"Language",type:"String"},6:{name:"CodecID",type:"String"},9122:{name:"CodecPrivate",type:"Binary"},362120:{name:"CodecName",type:"String"},13382:{name:"AttachmentLink",type:"Uint"},1742487:{name:"CodecSettings",type:"String"},1785920:{name:"CodecInfoURL",type:"String"},438848:{name:"CodecDownloadURL",type:"String"},42:{name:"CodecDecodeAll",type:"Uint"},12203:{name:"TrackOverlay",type:"Uint"},5802:{name:"CodecDelay",type:"Uint"},5819:{name:"SeekPreRoll",type:"Uint"},9764:{name:"TrackTranslate",type:"Container"},9980:{name:"TrackTranslateEditionUID",type:"Uint"},9919:{name:"TrackTranslateCodec",type:"Uint"},9893:{name:"TrackTranslateTrackID",type:"Binary"},96:{name:"Video",type:"Container"},26:{name:"FlagInterlaced",type:"Uint"},5048:{name:"StereoMode",type:"Uint"},5056:{name:"AlphaMode",type:"Uint"},5049:{name:"OldStereoMode",type:"Uint"},48:{name:"PixelWidth",type:"Uint"},58:{name:"PixelHeight",type:"Uint"},5290:{name:"PixelCropBottom",type:"Uint"},5307:{name:"PixelCropTop",type:"Uint"},5324:{name:"PixelCropLeft",type:"Uint"},5341:{name:"PixelCropRight",type:"Uint"},5296:{name:"DisplayWidth",type:"Uint"},5306:{name:"DisplayHeight",type:"Uint"},5298:{name:"DisplayUnit",type:"Uint"},5299:{name:"AspectRatioType",type:"Uint"},963876:{name:"ColourSpace",type:"Binary"},1029411:{name:"GammaValue",type:"Float"},230371:{name:"FrameRate",type:"Float"},97:{name:"Audio",type:"Container"},53:{name:"SamplingFrequency",type:"Float"},14517:{name:"OutputSamplingFrequency",type:"Float"},31:{name:"Channels",type:"Uint"},15739:{name:"ChannelPositions",type:"Binary"},8804:{name:"BitDepth",type:"Uint"},98:{name:"TrackOperation",type:"Container"},99:{name:"TrackCombinePlanes",type:"Container"},100:{name:"TrackPlane",type:"Container"},101:{name:"TrackPlaneUID",type:"Uint"},102:{name:"TrackPlaneType",type:"Uint"},105:{name:"TrackJoinBlocks",type:"Container"},109:{name:"TrackJoinUID",type:"Uint"},64:{name:"TrickTrackUID",type:"Uint"},65:{name:"TrickTrackSegmentUID",type:"Binary"},70:{name:"TrickTrackFlag",type:"Uint"},71:{name:"TrickMasterTrackUID",type:"Uint"},68:{name:"TrickMasterTrackSegmentUID",type:"Binary"},11648:{name:"ContentEncodings",type:"Container"},8768:{name:"ContentEncoding",type:"Container"},4145:{name:"ContentEncodingOrder",type:"Uint"},4146:{name:"ContentEncodingScope",type:"Uint"},4147:{name:"ContentEncodingType",type:"Uint"},4148:{name:"ContentCompression",type:"Container"},596:{name:"ContentCompAlgo",type:"Uint"},597:{name:"ContentCompSettings",type:"Binary"},4149:{name:"ContentEncryption",type:"Container"},2017:{name:"ContentEncAlgo",type:"Uint"},2018:{name:"ContentEncKeyID",type:"Binary"},2019:{name:"ContentSignature",type:"Binary"},2020:{name:"ContentSigKeyID",type:"Binary"},2021:{name:"ContentSigAlgo",type:"Uint"},2022:{name:"ContentSigHashAlgo",type:"Uint"},206814059:{name:"Cues",type:"Container"},59:{name:"CuePoint",type:"Container"},51:{name:"CueTime",type:"Uint"},55:{name:"CueTrackPositions",type:"Container"},119:{name:"CueTrack",type:"Uint"},113:{name:"CueClusterPosition",type:"Uint"},112:{name:"CueRelativePosition",type:"Uint"},50:{name:"CueDuration",type:"Uint"},4984:{name:"CueBlockNumber",type:"Uint"},106:{name:"CueCodecState",type:"Uint"},91:{name:"CueReference",type:"Container"},22:{name:"CueRefTime",type:"Uint"},23:{name:"CueRefCluster",type:"Uint"},4959:{name:"CueRefNumber",type:"Uint"},107:{name:"CueRefCodecState",type:"Uint"},155296873:{name:"Attachments",type:"Container"},8615:{name:"AttachedFile",type:"Container"},1662:{name:"FileDescription",type:"String"},1646:{name:"FileName",type:"String"},1632:{name:"FileMimeType",type:"String"},1628:{name:"FileData",type:"Binary"},1710:{name:"FileUID",type:"Uint"},1653:{name:"FileReferral",type:"Binary"},1633:{name:"FileUsedStartTime",type:"Uint"},1634:{name:"FileUsedEndTime",type:"Uint"},4433776:{name:"Chapters",type:"Container"},1465:{name:"EditionEntry",type:"Container"},1468:{name:"EditionUID",type:"Uint"},1469:{name:"EditionFlagHidden",type:"Uint"},1499:{name:"EditionFlagDefault",type:"Uint"},1501:{name:"EditionFlagOrdered",type:"Uint"},54:{name:"ChapterAtom",type:"Container"},13252:{name:"ChapterUID",type:"Uint"},5716:{name:"ChapterStringUID",type:"String"},17:{name:"ChapterTimeStart",type:"Uint"},18:{name:"ChapterTimeEnd",type:"Uint"},24:{name:"ChapterFlagHidden",type:"Uint"},1432:{name:"ChapterFlagEnabled",type:"Uint"},11879:{name:"ChapterSegmentUID",type:"Binary"},11964:{name:"ChapterSegmentEditionUID",type:"Uint"},9155:{name:"ChapterPhysicalEquiv",type:"Uint"},15:{name:"ChapterTrack",type:"Container"},9:{name:"ChapterTrackNumber",type:"Uint"},0:{name:"ChapterDisplay",type:"Container"},5:{name:"ChapString",type:"String"},892:{name:"ChapLanguage",type:"String"},894:{name:"ChapCountry",type:"String"},10564:{name:"ChapProcess",type:"Container"},10581:{name:"ChapProcessCodecID",type:"Uint"},1293:{name:"ChapProcessPrivate",type:"Binary"},10513:{name:"ChapProcessCommand",type:"Container"},10530:{name:"ChapProcessTime",type:"Uint"},10547:{name:"ChapProcessData",type:"Binary"},39109479:{name:"Tags",type:"Container"},13171:{name:"Tag",type:"Container"},9152:{name:"Targets",type:"Container"},10442:{name:"TargetTypeValue",type:"Uint"},9162:{name:"TargetType",type:"String"},9157:{name:"TagTrackUID",type:"Uint"},9161:{name:"TagEditionUID",type:"Uint"},9156:{name:"TagChapterUID",type:"Uint"},9158:{name:"TagAttachmentUID",type:"Uint"},10184:{name:"SimpleTag",type:"Container"},1443:{name:"TagName",type:"String"},1146:{name:"TagLanguage",type:"String"},1156:{name:"TagDefault",type:"Uint"},1159:{name:"TagString",type:"String"},1157:{name:"TagBinary",type:"Binary"}};function t(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e}function n(e,t){this.name=e||"Unknown",this.type=t||"Unknown"}function a(e,t){n.call(this,e,t||"Uint")}function r(e){return e.length%2===1?"0"+e:e}function i(e,t){n.call(this,e,t||"Float")}function o(e,t){n.call(this,e,t||"Container")}function c(e){o.call(this,"File","File"),this.setSource(e)}return n.prototype.updateBySource=function(){},n.prototype.setSource=function(e){this.source=e,this.updateBySource()},n.prototype.updateByData=function(){},n.prototype.setData=function(e){this.data=e,this.updateByData()},t(a,n),a.prototype.updateBySource=function(){this.data="";for(var e=0;e<this.source.length;e++){var t=this.source[e].toString(16);this.data+=r(t)}},a.prototype.updateByData=function(){var e=this.data.length/2;this.source=new Uint8Array(e);for(var t=0;t<e;t++){var n=this.data.substr(2*t,2);this.source[t]=parseInt(n,16)}},a.prototype.getValue=function(){return parseInt(this.data,16)},a.prototype.setValue=function(e){this.setData(r(e.toString(16)))},t(i,n),i.prototype.getFloatArrayType=function(){return this.source&&4===this.source.length?Float32Array:Float64Array},i.prototype.updateBySource=function(){var e=this.source.reverse(),t=new(this.getFloatArrayType())(e.buffer);this.data=t[0]},i.prototype.updateByData=function(){var e=new(this.getFloatArrayType())([this.data]),t=new Uint8Array(e.buffer);this.source=t.reverse()},i.prototype.getValue=function(){return this.data},i.prototype.setValue=function(e){this.setData(e)},t(o,n),o.prototype.readByte=function(){return this.source[this.offset++]},o.prototype.readUint=function(){for(var e=this.readByte(),t=8-e.toString(2).length,n=e-(1<<7-t),a=0;a<t;a++)n*=256,n+=this.readByte();return n},o.prototype.updateBySource=function(){for(this.data=[],this.offset=0;this.offset<this.source.length;this.offset=c){var t=this.readUint(),r=this.readUint(),c=Math.min(this.offset+r,this.source.length),s=this.source.slice(this.offset,c),u=e[t]||{name:"Unknown",type:"Unknown"},l=n;switch(u.type){case"Container":l=o;break;case"Uint":l=a;break;case"Float":l=i}var p=new l(u.name,u.type);p.setSource(s),this.data.push({id:t,idHex:t.toString(16),data:p})}},o.prototype.writeUint=function(e,t){for(var n=1,a=128;e>=a&&n<8;n++,a*=128);if(!t)for(var r=a+e,i=n-1;i>=0;i--){var o=r%256;this.source[this.offset+i]=o,r=(r-o)/256}this.offset+=n},o.prototype.writeSections=function(e){this.offset=0;for(var t=0;t<this.data.length;t++){var n=this.data[t],a=n.data.source,r=a.length;this.writeUint(n.id,e),this.writeUint(r,e),e||this.source.set(a,this.offset),this.offset+=r}return this.offset},o.prototype.updateByData=function(){var e=this.writeSections("draft");this.source=new Uint8Array(e),this.writeSections()},o.prototype.getSectionById=function(e){for(var t=0;t<this.data.length;t++){var n=this.data[t];if(n.id===e)return n.data}return null},t(c,o),c.prototype.fixDuration=function(e){var t=this.getSectionById(139690087);if(!t)return console.log("[fix-webm-duration] Segment section is missing"),!1;var n=t.getSectionById(88713574);if(!n)return console.log("[fix-webm-duration] Info section is missing"),!1;var a=n.getSectionById(710577);if(!a)return console.log("[fix-webm-duration] TimecodeScale section is missing"),!1;var r=n.getSectionById(1161);if(r){if(!(r.getValue()<=0))return console.log("[fix-webm-duration] Duration section is present"),!1;console.log("[fix-webm-duration] Duration section is present, but the value is empty"),r.setValue(e)}else console.log("[fix-webm-duration] Duration section is missing"),(r=new i("Duration","Float")).setValue(e),n.data.push({id:1161,data:r});return a.setValue(1e6),n.updateByData(),t.updateByData(),this.updateByData(),!0},c.prototype.toBlob=function(){return new Blob([this.source.buffer],{type:"video/webm"})},function(e,t,n){try{var a=new FileReader;a.onloadend=function(){try{var r=new c(new Uint8Array(a.result));r.fixDuration(t)&&(e=r.toBlob())}catch(i){}n(e)},a.readAsArrayBuffer(e)}catch(r){n(e)}}},e.exports?e.exports=a():window.ysFixWebmDuration=a()},15:function(e,t,n){e.exports=n(28)},20:function(e,t,n){},23:function(e,t,n){},28:function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a),i=n(12),o=n.n(i),c=(n(20),n(1)),s=n.n(c),u=n(2),l=n(3),p=n(4),m=n(6),d=n(5),y=n(7),f=(n(23),{getVideo:function(){var e=Object(u.a)(s.a.mark(function e(t){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",navigator.mediaDevices.getUserMedia({audio:!1,video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t.id,minWidth:1280,maxWidth:1920,minHeight:720,maxHeight:1080}}}).then(f.handleStream).catch(f.handleUserMediaError));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),getAudio:function(){var e=Object(u.a)(s.a.mark(function e(){var t,n,a=arguments;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:null,n=!0,t&&(n={deviceId:t.deviceId}),e.abrupt("return",navigator.mediaDevices.getUserMedia({audio:n,video:!1}).then(f.handleStream).catch(f.handleUserMediaError));case 4:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),handleStream:function(){var e=Object(u.a)(s.a.mark(function e(t){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),handleUserMediaError:function(){var e=Object(u.a)(s.a.mark(function e(t){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:throw Error(t);case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()}),h=n(9),g=(0,window.require)("fs"),v={save:function(e,t,n){return new Promise(function(a,r){var i="".concat(t,"/").concat(n);g.writeFile(i,e,function(e){e?r(e):(a(i),console.log(i))})})}},S=function(e){function t(){var e,n;Object(l.a)(this,t);for(var a=arguments.length,r=new Array(a),i=0;i<a;i++)r[i]=arguments[i];return(n=Object(m.a)(this,(e=Object(d.a)(t)).call.apply(e,[this].concat(r)))).state={audioSources:[],selectedSource:{}},n._handleChange=function(e){var t=n.state.audioSources.find(function(t){return t.deviceId===e.target.value});n.selectSource(t)},n.selectSource=function(e){e&&(n.setState({selectedSource:e}),localStorage.setItem("_audio_source",e.deviceId),n.props.onSelect(e))},n}return Object(y.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){this.getSources()}},{key:"getSources",value:function(){var e=Object(u.a)(s.a.mark(function e(){var t,n,a=this;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.enumerateDevices();case 2:return t=e.sent,n=t.filter(function(e){return"audioinput"===e.kind}),this.setState({audioSources:n},function(){a._loadFromStorage()}),e.abrupt("return",n);case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"_loadFromStorage",value:function(){var e=localStorage.getItem("_audio_source"),t=this.state.audioSources.find(function(t){return t.deviceId===e});t?this.selectSource(t):this.selectSource(this.state.audioSources[0])}},{key:"render",value:function(){var e=this.state;return r.a.createElement("div",null,r.a.createElement("div",null,"Audio input source"),r.a.createElement("select",{value:e.selectedSource.deviceId,onChange:this._handleChange,className:"settings-select"},e.audioSources.map(function(e){return r.a.createElement("option",{key:e.deviceId,value:e.deviceId},e.label)})))}}]),t}(a.Component);S.defaultProps={onSelect:function(){}};var C=S,w=n(8),U=(0,window.require)("electron").desktopCapturer,b=function(e){function t(){var e,n;Object(l.a)(this,t);for(var a=arguments.length,r=new Array(a),i=0;i<a;i++)r[i]=arguments[i];return(n=Object(m.a)(this,(e=Object(d.a)(t)).call.apply(e,[this].concat(r)))).state={screenSources:[],windowSources:[],selectedSource:{}},n._handleChange=function(e){var t=n.state,a=t.screenSources,r=t.windowSources,i=[].concat(Object(w.a)(a),Object(w.a)(r)).find(function(t){return t.id===e.target.value});n.selectSource(i)},n.selectSource=function(e){e&&(n.setState({selectedSource:e}),localStorage.setItem("_video_source",e.id),n.props.onSelect(e))},n}return Object(y.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){this.getSources()}},{key:"getSources",value:function(){var e=this;U.getSources({types:["window","screen"]},function(t,n){var a=n.filter(function(e){return e.id.includes("window")}),r=n.filter(function(e){return e.id.includes("screen")});e.setState({windowSources:a,screenSources:r},function(){e._loadFromStorage()})})}},{key:"_loadFromStorage",value:function(){var e=this.state,t=e.screenSources,n=e.windowSources,a=localStorage.getItem("_video_source"),r=[].concat(Object(w.a)(t),Object(w.a)(n)).find(function(e){return e.id===a});r?this.selectSource(r):this.selectSource(t[0])}},{key:"render",value:function(){var e=this.state;return r.a.createElement("div",null,r.a.createElement("div",null,"Video input source"),r.a.createElement("select",{value:e.selectedSource.id,onChange:this._handleChange,className:"settings-select"},r.a.createElement("option",null,"-- SCREENS --"),e.screenSources.map(function(e){return r.a.createElement("option",{key:e.id,value:e.id},e.name)}),r.a.createElement("option",null,"-- WINDOWS --"),e.windowSources.map(function(e){return r.a.createElement("option",{key:e.id,value:e.id},e.name)})))}}]),t}(a.Component);b.defaultProps={onSelect:function(){}};var k=b,D=function(e){function t(e){var n;return Object(l.a)(this,t),(n=Object(m.a)(this,Object(d.a)(t).call(this,e))).state={isDrawActive:!0},n.toggleDrawActive=function(){n.setState(function(e){return{isDrawActive:!e.isDrawActive}},function(){n.draw()})},n.canvas=r.a.createRef(),n.canDraw=!1,n}return Object(y.a)(t,e),Object(p.a)(t,[{key:"componentDidUpdate",value:function(){var e=Object(u.a)(s.a.mark(function e(){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.props.audioDevice?this.start():this.stop();case 1:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"componentDidMount",value:function(){var e=Object(u.a)(s.a.mark(function e(){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:this.canvasCtx=this.canvas.current.getContext("2d"),this.props.audioDevice&&this.start();case 2:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"start",value:function(){this.startAudio(),this.startCanvas(),this.canDraw=!0,this.draw()}},{key:"stop",value:function(){this.canDraw=!1,this.clearCanvas()}},{key:"startAudio",value:function(){var e=Object(u.a)(s.a.mark(function e(){var t,n;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.props.audioDevice){e.next=10;break}return e.next=3,f.getAudio(this.props.audioDevice);case 3:this.audioStream=e.sent,t=new(window.AudioContext||window.webkitAudioContext),n=t.createAnalyser(),t.createMediaStreamSource(this.audioStream).connect(n),n.fftSize=256,this.analyser=n,this.bufferLength=n.frequencyBinCount,this.dataArray=new Uint8Array(this.bufferLength);case 10:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}()},{key:"startCanvas",value:function(){var e=this.canvas.current;e.width=this.props.width||100,e.height=this.props.height||100}},{key:"clearCanvas",value:function(){var e=this.canvas.current,t=e.width,n=e.height;this.canvasCtx.clearRect(0,0,t,n)}},{key:"getBarValues",value:function(){var e=this.bufferLength,t=this.dataArray,n=this.analyser;if(!this.audioStream)return!1;n.getByteFrequencyData(t);for(var a=Math.floor(e/3),r=Math.max.apply(Math,Object(w.a)(t)),i=[],o=0;o<3;o++){var c=this.average(t.slice(0,a));i.push(Math.trunc(10*(c/r||0))+"0")}}},{key:"average",value:function(e){var t=e.length;return e.reduce(function(e,t){return t+e})/t}},{key:"draw",value:function(){if(this.canDraw&&this.state.isDrawActive){var e=this.canvas.current,t=e.width,n=e.height,a=this.canvasCtx,r=this.bufferLength,i=this.dataArray,o=this.analyser;if(this.clearCanvas(),requestAnimationFrame(this.draw.bind(this)),!this.audioStream)return!1;o.getByteFrequencyData(i);for(var c,s=t/r*2.5,u=0,l=0;l<r;l++)c=i[l]/2,a.fillStyle="rgb(50, "+(c+100)+",50)",a.fillRect(u,n-c/2,s,c),u+=s+1}}},{key:"render",value:function(){var e=this.state.isDrawActive?{}:{backgroundColor:"#333"};return r.a.createElement("div",null,r.a.createElement("canvas",{style:e,onClick:this.toggleDrawActive,ref:this.canvas,height:50,width:100}))}}]),t}(a.Component);D.defaultProps={audioDevice:null};a.Component;var T=D,E=function(e){function t(e){var n;return Object(l.a)(this,t),(n=Object(m.a)(this,Object(d.a)(t).call(this,e))).state={totalSeconds:0},n.timer=null,n}return Object(y.a)(t,e),Object(p.a)(t,[{key:"start",value:function(){var e=this;this.timer=setInterval(function(){return e.increment()},1e3)}},{key:"stop",value:function(){clearInterval(this.timer)}},{key:"reset",value:function(){this.setState({totalSeconds:0})}},{key:"increment",value:function(){this.setState(function(e){return{totalSeconds:e.totalSeconds+1}})}},{key:"numberFormat",value:function(e){return("00"+e).slice(-2)}},{key:"getTime",value:function(){var e=this.state.totalSeconds,t=Math.floor(e/3600),n=Math.floor((e-3600*t)/60);return{seconds:e-(3600*t+60*n),minutes:n,hours:t}}},{key:"render",value:function(){var e=this.getTime(),t=e.seconds,n=e.minutes,a=e.hours;return r.a.createElement("div",{className:"time-counter"},r.a.createElement("span",null,a,":",this.numberFormat(n),":",this.numberFormat(t)))}}]),t}(a.Component),B=n(14),x=(0,window.require)("electron").remote,A=function(e){function t(e){var n;return Object(l.a)(this,t),(n=Object(m.a)(this,Object(d.a)(t).call(this,e))).state={folder:"",filename:"",hasTime:!1,format:""},n.selectFolder=Object(u.a)(s.a.mark(function e(){var t;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:(t=x.dialog.showOpenDialog({properties:["openDirectory"]}))&&(n.setState({folder:t[0]}),localStorage.setItem("_filepath_folder",t[0]));case 2:case"end":return e.stop()}},e)})),n.handleChange=function(e){var t=e.target,a=t.name,r="checkbox"===t.type?t.checked:t.value;n.setState(Object(B.a)({},a,r)),localStorage.setItem("_filepath_".concat(a),r)},n.formatList=["mp4","avi"],n}return Object(y.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){var e=localStorage.getItem("_filepath_folder")||"",t=localStorage.getItem("_filepath_format")||"webm",n="true"===localStorage.getItem("_filepath_hasTime");this.setState({folder:e,format:t,hasTime:n})}},{key:"render",value:function(){var e=this.state,t=e.folder,n=e.filename,a=e.format,i=e.hasTime;return r.a.createElement("div",{className:"save-file-path"},r.a.createElement("input",{name:"folder",type:"text",onClick:this.selectFolder,value:t,placeholder:"folder",readOnly:!0}),r.a.createElement("input",{name:"filename",type:"text",onChange:this.handleChange,value:n,placeholder:"file name"}),r.a.createElement("select",{name:"format",onChange:this.handleChange,value:a},r.a.createElement("option",{value:"webm"},"webm (default)"),this.formatList.map(function(e){return r.a.createElement("option",{key:e,value:e},e)})),r.a.createElement("label",null,r.a.createElement("input",{name:"hasTime",type:"checkbox",onChange:this.handleChange,checked:i}),"Time"))}}]),t}(a.Component),I=(0,window.require)("electron"),O=I.ipcRenderer,F=I.remote,R=function(e){function t(e){var n;return Object(l.a)(this,t),(n=Object(m.a)(this,Object(d.a)(t).call(this,e))).state={isRecording:!1,isPaused:!1,canRecordSystemAudio:!1,videoTarget:null,audioTarget:null,systemAudioTarget:null,isLoading:!1},n.onVideoSourceSelect=function(){var e=Object(u.a)(s.a.mark(function e(t){var a;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n.setState({videoTarget:t}),a=n.video.current,f.getVideo(t).then(function(e){console.log(t,e),a.srcObject=e,a.muted=!0,a.onloadedmetadata=function(e){return a.play()}}).catch(function(){var e=n.videoSourceList.current;e.selectSource(e.state.screenSources[0])});case 3:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),n.onAudioSourceSelect=function(){var e=Object(u.a)(s.a.mark(function e(t){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n.setState({audioTarget:t}),f.getAudio(t).then(function(e){console.log(t,e)}).catch(function(){var e=n.audioSourceList.current;e.selectSource(e.state.audioSources[0])});case 2:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),n.onRecordSystemAudioChange=function(){var e=Object(u.a)(s.a.mark(function e(t){var a,r;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(a=t.currentTarget.checked,r=!1,!a){e.next=6;break}return e.next=5,f.getAudio();case 5:r=e.sent;case 6:n.setState({canRecordSystemAudio:a,systemAudioTarget:r});case 7:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),n.start=Object(u.a)(s.a.mark(function e(){var t,a,r,i,o,c,u,l;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=n.savefilepath.current,!n.state.isLoading){e.next=3;break}return e.abrupt("return",!1);case 3:if(t.state.folder){e.next=7;break}return F.dialog.showMessageBox({message:"Select a folder to save the file"}),n.savefilepath.current.selectFolder(),e.abrupt("return",!1);case 7:if(a=n.state,r=a.videoTarget,i=a.audioTarget,o=a.isRecording,a.canRecordSystemAudio,a.systemAudioTarget,c=n.video.current.srcObject,!r||o){e.next=19;break}if(!i){e.next=15;break}return e.next=12,f.getAudio(i);case 12:u=e.sent,l=u.getAudioTracks(),c.addTrack(l[0]);case 15:h.a.start(c),n.setState({isRecording:!0,isPaused:!1}),n.timeCounter.current.start(),O.send("win:start");case 19:case"end":return e.stop()}},e)})),n.pause=Object(u.a)(s.a.mark(function e(){var t,a,r;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=n.state,a=t.isRecording,r=t.isPaused,a&&!r&&(h.a.pause(),n.setState({isRecording:!0,isPaused:!0}),n.timeCounter.current.stop(),O.send("win:pause"));case 2:case"end":return e.stop()}},e)})),n.resume=Object(u.a)(s.a.mark(function e(){var t,a,r;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:t=n.state,a=t.isRecording,r=t.isPaused,a&&r&&(h.a.resume(),n.setState({isRecording:!0,isPaused:!1}),n.timeCounter.current.start(),O.send("win:resume"));case 2:case"end":return e.stop()}},e)})),n.stop=Object(u.a)(s.a.mark(function e(){var t,a;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.state.isRecording){e.next=11;break}return t=1e3*n.timeCounter.current.state.totalSeconds,e.next=5,h.a.stop(t);case 5:return a=e.sent,n.setState({isRecording:!1,isPaused:!1}),n.timeCounter.current.stop(),n.timeCounter.current.reset(),O.send("win:stop"),e.abrupt("return",n.saveFile(a));case 11:case"end":return e.stop()}},e)})),n.saveFile=function(){var e=Object(u.a)(s.a.mark(function e(t){var a,r,i,o,c;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return a=n.savefilepath.current,r="".concat(a.state.folder||".","/"),i=a.state.hasTime,o=a.state.format,c="".concat(a.state.filename||Date.now().toString()).concat(i?Date.now().toString():"",".webm"),e.next=4,v.save(t,r,c);case 4:"webm"!==o&&(n.setState({isLoading:!0}),O.send("win:convert-video",{folder:r,fileName:c,type:o})),console.log("save");case 6:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),n.deleteRecording=Object(u.a)(s.a.mark(function e(){return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.state.isRecording){e.next=8;break}return e.next=4,h.a.stop();case 4:n.setState({isRecording:!1,isPaused:!1}),n.timeCounter.current.stop(),n.timeCounter.current.reset(),O.send("win:cancel");case 8:case"end":return e.stop()}},e)})),n.cancelRecording=Object(u.a)(s.a.mark(function e(){var t;return s.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n.pause(),t={type:"question",buttons:["No","Yes"],defaultId:2,title:"Question",message:"Do you want to delete the current recording?",detail:"it cannot be undone"},F.dialog.showMessageBox(null,t,function(e){1===e&&n.deleteRecording()});case 3:case"end":return e.stop()}},e)})),n.video=r.a.createRef(),n.timeCounter=r.a.createRef(),n.savefilepath=r.a.createRef(),n.videoSourceList=r.a.createRef(),n.audioSourceList=r.a.createRef(),n}return Object(y.a)(t,e),Object(p.a)(t,[{key:"componentDidMount",value:function(){var e=this;this.handleShortcuts(),O.on("back:convert-video:complete",function(){e.setState({isLoading:!1})})}},{key:"handleShortcuts",value:function(){var e=this;O.on("play",function(){var t=e.state,n=t.isRecording,a=t.isPaused;n||a?n&&!a?e.pause():e.resume():e.start()}),O.on("stop",function(){e.stop()}),O.on("delete",function(){e.cancelRecording()})}},{key:"controlButtons",value:function(){var e=this.state,t=e.isRecording,n=e.isPaused;return t&&!n?r.a.createElement(r.a.Fragment,null,r.a.createElement("button",{className:"record-control-button",onClick:this.cancelRecording},r.a.createElement("i",{className:"fas fa-trash-alt"}),r.a.createElement("span",null,"Delete")),r.a.createElement("button",{className:"record-control-button",onClick:this.pause},r.a.createElement("i",{className:"fas fa-pause"}),r.a.createElement("span",null,"Pause")),r.a.createElement("button",{className:"record-control-button",onClick:this.stop},r.a.createElement("i",{className:"fas fa-stop"}),r.a.createElement("span",null,"Stop"))):r.a.createElement(r.a.Fragment,null,r.a.createElement("button",{className:"record-control-button",onClick:this.cancelRecording},r.a.createElement("i",{className:"fas fa-trash-alt"}),r.a.createElement("span",null,"Delete")),r.a.createElement("button",{className:"record-control-button",onClick:this.resume},r.a.createElement("i",{className:"fas fa-play"}),r.a.createElement("span",null,"Resume")),r.a.createElement("button",{className:"record-control-button",onClick:this.stop},r.a.createElement("i",{className:"fas fa-stop"}),r.a.createElement("span",null,"Stop")))}},{key:"render",value:function(){var e=this.state,t=e.isRecording,n=e.canRecordSystemAudio,a=e.audioTarget,i=e.isLoading,o="App";return t&&(o+=" is-recording"),r.a.createElement("div",{className:o},r.a.createElement("div",{className:"app-container"},r.a.createElement("video",{className:"video-preview",ref:this.video}),r.a.createElement("div",{className:"audio-visualization-container"},r.a.createElement(T,{height:50,width:100,audioDevice:a})),r.a.createElement("div",{className:"settings-control"},r.a.createElement("div",{className:"settings-sources"},r.a.createElement(k,{ref:this.videoSourceList,onSelect:this.onVideoSourceSelect}),r.a.createElement(C,{ref:this.audioSourceList,onSelect:this.onAudioSourceSelect}),r.a.createElement("label",{style:{display:"none"}},r.a.createElement("input",{disabled:!0,type:"checkbox",checked:n,onChange:this.onRecordSystemAudioChange})," ","Record System Audio")),r.a.createElement("div",{className:"record-control"},r.a.createElement("button",{className:"record-control-button",onClick:this.start},r.a.createElement("i",{className:"fas fa-circle"}),r.a.createElement("span",null,"Record")))),r.a.createElement("div",{className:"recording-control"},r.a.createElement("div",{className:"time-counter-container"},r.a.createElement(E,{ref:this.timeCounter,isActive:!0})),r.a.createElement("div",{className:"record-control"},this.controlButtons())),r.a.createElement("div",{className:"save-file-container"},r.a.createElement(A,{ref:this.savefilepath}))),r.a.createElement("div",{className:"loading-container"+(i?" is-loading":"")},r.a.createElement("span",null,"Wait . . .")))}}]),t}(a.Component);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));o.a.render(r.a.createElement(R,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})},9:function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return c});var a=n(1),r=n.n(a),i=n(2),o=n(13),c={recorder:null,blobs:[],start:function(e){c.recorder||(c.recorder=new MediaRecorder(e),c.blobs=[],c.recorder.ondataavailable=function(e){c.blobs.push(e.data)},c.recorder.start())},stop:function(){var e=Object(i.a)(r.a.mark(function e(t){return r.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e){c.recorder&&null!==c.recorder.state&&(c.recorder.onstop=function(){var n=new Blob(c.blobs,{type:"video/webm"});o(n,t,function(t){c.toArrayBuffer(t,function(t){var n=c.toBuffer(t);e(n)}),c.recorder=null})},c.recorder.stop())}));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),pause:function(){c.recorder&&"recording"===c.recorder.state&&c.recorder.pause()},resume:function(){c.recorder&&"paused"===c.recorder.state&&c.recorder.resume()},toArrayBuffer:function(e,t){var n=new FileReader;n.onload=function(){var e=this.result;t(e)},n.readAsArrayBuffer(e)},toBuffer:function(t){for(var n=new e(t.byteLength),a=new Uint8Array(t),r=0;r<a.byteLength;r++)n[r]=a[r];return n}}}).call(this,n(24).Buffer)}},[[15,1,2]]]);
//# sourceMappingURL=main.f2fbc370.chunk.js.map