Your IP : 3.145.112.163


Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/main/recorder/
Upload File :
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/js/main/recorder/recorder.min.js

(function(e){if(typeof BX.Recorder!=="undefined")return;var t={"audio/mp3":true};var i={idle:0,recording:1,paused:2};BX.Recorder=function(t,o){if(!t instanceof e.MediaStream)throw"stream must be of type MediaStream";if(!BX.type.isPlainObject(o))o={};this.stream=t;this.options={type:o.type&&BX.Recorder.isTypeSupported(o.type)?o.type:"audio/mp3"};this.state=i.idle;this.audioContext=null;this.mediaStreamNode=null;this.scriptNode=null;this.analyserNode=null;this.worker=new e.Worker("/bitrix/js/main/recorder/encoder.js");this.worker.postMessage({action:"init",type:this.options.type});this.worker.onmessage=function(e){switch(e.data.action){case"result":BX.onCustomEvent(this,"stop",[e.data.result]);break}}.bind(this)};BX.Recorder.isSupported=function(){return typeof e.Blob!=="undefined"&&typeof e.Worker!=="undefined"&&typeof e.URL!=="undefined"&&typeof e.MediaStream!=="undefined"&&(typeof e.AudioContext!=="undefined"||typeof e.webkitAudioContext!=="undefined")};BX.Recorder.isTypeSupported=function(e){return t[e]===true};BX.Recorder.prototype.start=function(){var t=this;if(this.state!==i.idle)throw"recording can not be started right now";this.audioContext=new(e.AudioContext||e.webkitAudioContext);this.scriptNode=this.audioContext.createScriptProcessor(16384,1,1);this.scriptNode.connect(this.audioContext.destination);this.mediaStreamNode=this.audioContext.createMediaStreamSource(this.stream);this.mediaStreamNode.connect(this.scriptNode);this.scriptNode.onaudioprocess=function(e){if(t.state!==i.recording)return;if(!t.worker)return;var o=e.inputBuffer.getChannelData(0);t.worker.postMessage({action:"record",input:o})};t.worker.postMessage({action:"start"});this.state=i.recording};BX.Recorder.prototype.attachAnalyser=function(e){if(this.state!==i.recording)throw"recorder is in the wrong state";if(!e){e={}}if(!this.analyserNode){this.analyserNode=this.audioContext.createAnalyser();this.analyserNode.fftSize=e.fftSize||128;this.analyserNode.minDecibels=e.minDecibels||-80;this.analyserNode.maxDecibels=e.maxDecibels||-10;this.mediaStreamNode.connect(this.analyserNode)}};BX.Recorder.prototype.stop=function(){if(this.state!==i.recording)throw"recording can not be stopped right now";this.worker.postMessage({action:"stop"});if(this.analyserNode)this.analyserNode.disconnect();if(this.scriptNode)this.scriptNode.disconnect();if(this.mediaStreamNode)this.mediaStreamNode.disconnect();if(this.audioContext)this.audioContext.close();this.analyserNode=null;this.scriptNode=null;this.mediaStreamNode=null;this.audioContext=null;this.state=i.idle};BX.Recorder.prototype.pause=function(){if(this.state!==i.recording)throw"recording can not be paused right now";this.state=i.paused};BX.Recorder.prototype.resume=function(){if(this.state!==i.paused)throw"recording can not be resumed right now";this.state=i.recording};BX.Recorder.prototype.replaceStream=function(t){if(!t instanceof e.MediaStream)throw"stream must be of type MediaStream";this.stream=t;if(this.analyserNode){this.analyserNode.disconnect()}this.mediaStreamNode.disconnect();this.mediaStreamNode=this.audioContext.createMediaStreamSource(this.stream);this.mediaStreamNode.connect(this.scriptNode);if(this.analyserNode){this.mediaStreamNode.connect(this.analyserNode)}};BX.Recorder.prototype.getState=function(){return this.state};BX.Recorder.prototype.dispose=function(){this.stream=null}})(window);
//# sourceMappingURL=recorder.map.js