Your IP : 18.117.83.104


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/main/recorder/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/main/recorder/recorder.min.js

(function(t){if(typeof BX.Recorder!=="undefined")return;var e={"audio/mp3":true};var i={idle:0,recording:1,paused:2};BX.Recorder=function(e,o){if(!e instanceof t.MediaStream)throw"stream must be of type MediaStream";if(!BX.type.isPlainObject(o))o={};this.stream=e;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.worker=new t.Worker("/bitrix/js/main/recorder/encoder.js");this.worker.postMessage({action:"init",type:this.options.type});this.worker.onmessage=function(t){switch(t.data.action){case"result":BX.onCustomEvent(this,"stop",[t.data.result]);break}}.bind(this)};BX.Recorder.isSupported=function(){return typeof t.Blob!=="undefined"&&typeof t.Worker!=="undefined"&&typeof t.URL!=="undefined"&&typeof t.MediaStream!=="undefined"&&(typeof t.AudioContext!=="undefined"||typeof t.webkitAudioContext!=="undefined")};BX.Recorder.isTypeSupported=function(t){return e[t]===true};BX.Recorder.prototype.start=function(){var e=this;if(this.state!==i.idle)throw"recording can not be started right now";this.audioContext=new(t.AudioContext||t.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(t){if(e.state!==i.recording)return;if(!e.worker)return;var o=t.inputBuffer.getChannelData(0);e.worker.postMessage({action:"record",input:o})};e.worker.postMessage({action:"start"});this.state=i.recording};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.scriptNode)this.scriptNode.disconnect();if(this.mediaStreamNode)this.mediaStreamNode.disconnect();if(this.audioContext)this.audioContext.close();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(e){if(!e instanceof t.MediaStream)throw"stream must be of type MediaStream";this.stream=e;this.mediaStreamNode.disconnect();this.mediaStreamNode=this.audioContext.createMediaStreamSource(this.stream);this.mediaStreamNode.connect(this.scriptNode)};BX.Recorder.prototype.getState=function(){return this.state};BX.Recorder.prototype.dispose=function(){this.stream=null}})(window);
//# sourceMappingURL=recorder.map.js