Telegram Web, preconfigured for usage in I2P. http://web.telegram.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
5.7 KiB

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Recorder=t():e.Recorder=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";(function(t){var o=n(2),i=function(e){var n=this,o=t.AudioContext||t.webkitAudioContext;if(!i.isRecordingSupported())throw new Error("Recording is not supported in this browser");this.state="inactive",this.eventTarget=t.document.createDocumentFragment(),this.audioContext=new o,this.monitorNode=this.audioContext.createGain(),this.config=Object.assign({bufferLength:4096,encoderApplication:2049,encoderFrameSize:20,encoderPath:"encoderWorker.min.js",encoderSampleRate:48e3,leaveStreamOpen:!1,maxBuffersPerPage:40,monitorGain:0,numberOfChannels:1,originalSampleRate:this.audioContext.sampleRate,resampleQuality:3,mediaTrackConstraints:!0,streamPages:!1,wavBitDepth:16,wavSampleRate:this.audioContext.sampleRate},e),this.initWorker(),this.setMonitorGain(this.config.monitorGain),this.scriptProcessorNode=this.audioContext.createScriptProcessor(this.config.bufferLength,this.config.numberOfChannels,this.config.numberOfChannels),this.scriptProcessorNode.onaudioprocess=function(e){n.encodeBuffers(e.inputBuffer)}};i.isRecordingSupported=function(){return(t.AudioContext||t.webkitAudioContext)&&o.isSupported},i.prototype.addEventListener=function(e,t,n){this.eventTarget.addEventListener(e,t,n)},i.prototype.clearStream=function(){this.stream&&(this.stream.getTracks?this.stream.getTracks().forEach(function(e){e.stop()}):this.stream.stop(),delete this.stream)},i.prototype.encodeBuffers=function(e){if("recording"===this.state){for(var t=[],n=0;n<e.numberOfChannels;n++)t[n]=e.getChannelData(n);this.encoder.postMessage({command:"encode",buffers:t})}},i.prototype.initStream=function(){var e=this,n=function(n){return e.stream=n,e.sourceNode=e.audioContext.createMediaStreamSource(n),e.sourceNode.connect(e.scriptProcessorNode),e.sourceNode.connect(e.monitorNode),e.eventTarget.dispatchEvent(new t.Event("streamReady")),n},i=function(n){throw e.eventTarget.dispatchEvent(new t.ErrorEvent("streamError",{error:n})),n},r={audio:this.config.mediaTrackConstraints};return this.stream?(this.eventTarget.dispatchEvent(new t.Event("streamReady")),t.Promise.resolve(this.stream)):o(r).then(n,i)},i.prototype.initWorker=function(){var e=this;this.encoder=new t.Worker(this.config.encoderPath),this.config.streamPages?this.encoder.addEventListener("message",function(t){e.streamPage(t.data)}):(this.recordedPages=[],this.totalLength=0,this.encoder.addEventListener("message",function(t){e.storePage(t.data)}))},i.prototype.pause=function(){"recording"===this.state&&(this.state="paused",this.eventTarget.dispatchEvent(new t.Event("pause")))},i.prototype.removeEventListener=function(e,t,n){this.eventTarget.removeEventListener(e,t,n)},i.prototype.resume=function(){"paused"===this.state&&(this.state="recording",this.eventTarget.dispatchEvent(new t.Event("resume")))},i.prototype.setMonitorGain=function(e){this.monitorNode.gain.setTargetAtTime(e,this.audioContext.currentTime,.01)},i.prototype.start=function(){"inactive"===this.state&&this.stream&&(this.encoder.postMessage(Object.assign({command:"init"},this.config)),this.encodeBuffers=function(){delete this.encodeBuffers},this.state="recording",this.monitorNode.connect(this.audioContext.destination),this.scriptProcessorNode.connect(this.audioContext.destination),this.eventTarget.dispatchEvent(new t.Event("start")))},i.prototype.stop=function(){"inactive"!==this.state&&(this.state="inactive",this.monitorNode.disconnect(),this.scri