Your IP : 3.23.85.47


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/socialnetwork/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/socialnetwork/video_recorder.min.js

(function(){if(window.BX.VideoRecorder)return;BX.VideoRecorder={popupPermissionsShown:false,popupConfirm:null,constraints:{audio:{},video:{width:1280,height:720,facingMode:"user"}},analyserNode:null,activeFormID:null,chunks:[],bindedForms:[],recorderInterval:5e3,transformLimit:0,transformTime:70,transformTimerShown:false,errorCode:null,getScreenWidth:function(){if(!document.fullscreenElement&&!document.mozFullScreenElement&&!document.webkitFullscreenElement){return document.body.clientWidth}else{return window.screen.width}},getScreenHeight:function(){return document.documentElement.clientHeight},isPermissionsAsked:function(){return BX.VideoRecorder.popupPermissionsShown},isAvailable:function(e){e=e===true;var o=BX.VideoRecorder.error=null;if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia||typeof MediaRecorder==="undefined"){o="Not available or old browser";BX.VideoRecorder.errorCode="BLOG_VIDEO_RECORD_REQUIREMENTS"}else if(BX.browser.IsChrome()&&location.protocol!=="https:"){o="In chrome works on https only";BX.VideoRecorder.errorCode="BLOG_VIDEO_RECORD_ERROR_CHROME_HTTPS"}else if(BX.browser.IsIE()){o="Not available in IE";BX.VideoRecorder.errorCode="BLOG_VIDEO_RECORD_REQUIREMENTS"}if(o){if(e){console.log(o)}return false}return true},bindEvents:function(e){if(!BX.VideoRecorder.isAvailable()){return}if(BX.VideoRecorder.bindedForms.indexOf(e.params.formID)!==-1){return}BX.VideoRecorder.bindedForms.push(e.params.formID);BX.addCustomEvent(e.eventNode,"onFileIsAdded",function(e,o,r,d){setTimeout(function(){if(d["hasTobeInserted"]===true)o.insertFile(e.id)},1e3)});BX.addCustomEvent(window,"onAddVideoMessage",function(o,r){if(!r){return}for(var d in e.controllers){if(e.controllers.hasOwnProperty(d)&&e.controllers[d]["storage"]==="disk"&&r===e.params.formID){e.controllers[d].handler.agent.onChange([o]);break}}})},showLayout:function(){BX.VideoRecorder.lockScroll();BX.VideoRecorder.recordCount=0;BX.VideoRecorder.startCount=5;BX.VideoRecorder.state="idle";BX.VideoRecorder.transformTimeLeft=BX.VideoRecorder.transformTime;BX.VideoRecorder.transformTimerShown=false;clearInterval(BX.VideoRecorder.recordInterval);BX.VideoRecorder.layout=BX.create("div",{props:{className:"bx-videomessage-video-wrapper"},children:[BX.create("div",{props:{className:"bx-videomessage-video-close"},events:{click:function(){BX.VideoRecorder.hideLayout()}}}),BX.VideoRecorder.videoOverlay=BX.create("div",{props:{className:"bx-videomessage-video-overlay"},style:{height:BX.VideoRecorder.getScreenHeight()+"px"},children:[BX.VideoRecorder.startTimer=BX.create("div",{props:{className:"bx-videomessage-video-starttimer"},text:"5"})]}),BX.VideoRecorder.videoContainer=BX.create("div",{props:{className:"bx-videomessage-video-container"},style:{height:BX.VideoRecorder.getScreenHeight()+"px"},children:[BX.VideoRecorder.videoWrap=BX.create("div",{props:{className:"bx-videomessage-video-wrap"},style:{height:BX.VideoRecorder.getScreenHeight()+"px"},children:[BX.VideoRecorder.waterMark=BX.create("div",{props:{className:"bx-videomessage-watermark"},style:{display:"none"},html:BX.message("BLOG_VIDEO_RECORD_LOGO")}),BX.VideoRecorder.transformTimeContainer=BX.create("div",{props:{className:"bx-videomessage-transform-time-container"},children:[BX.create("span",{props:{className:"bx-videomessage-transform-time-close"},html:"",events:{click:BX.VideoRecorder.hideTransformTimer}}),BX.create("span",{props:{className:"bx-videomessage-transform-time-text"},html:BX.message("BLOG_VIDEO_RECORD_TRANFORM_LIMIT_TEXT")})]}),BX.VideoRecorder.outputVideo=BX.create("video",{props:{className:"bx-videomessage-video",width:BX.VideoRecorder.getScreenWidth(),loop:false},events:{playing:function(){if(BX.VideoRecorder.state==="idle"){BX.VideoRecorder.resize();BX.VideoRecorder.beforeRecord()}},ended:function(){BX.VideoRecorder.state="idle";BX.VideoRecorder.buttonStop.style.display="none";BX.VideoRecorder.buttonPlay.style.display="block"}}}),BX.VideoRecorder.buttonPlay=BX.create("span",{props:{className:"bx-videomessage-playbutton"},events:{click:function(){if(BX.VideoRecorder.state==="idle"){BX.VideoRecorder.outputVideo.play();BX.VideoRecorder.outputVideo.volume=1;BX.VideoRecorder.state="playing";BX.VideoRecorder.buttonStop.style.display="inline-block";BX.VideoRecorder.buttonPlay.style.display="none"}}}}),BX.VideoRecorder.panel=BX.create("div",{props:{className:"bx-videomessage-panel"},style:{display:"none"},children:[BX.VideoRecorder.recordTimer=BX.create("span",{props:{className:"bx-videomessage-video-timer"},text:"00:00"}),BX.VideoRecorder.buttonStop=BX.create("span",{props:{className:"webform-button webform-button-blue webform-button-rounded"},text:BX.message("BLOG_VIDEO_RECORD_STOP_BUTTON"),events:{click:function(e){if(BX.VideoRecorder.state==="recording"){BX.VideoRecorder.state="idle";BX.VideoRecorder.recorder.stop();BX.hide(BX.VideoRecorder.recordMark);BX.hide(BX.VideoRecorder.analyzerElement);clearInterval(BX.VideoRecorder.recordInterval);BX.VideoRecorder.buttonPlay.style.display="block";BX.VideoRecorder.buttonStop.style.display="none";return false}else if(BX.VideoRecorder.state==="playing"){BX.VideoRecorder.outputVideo.pause();BX.VideoRecorder.state="idle";BX.VideoRecorder.buttonStop.style.display="none";BX.VideoRecorder.buttonPlay.style.display="block"}}}}),BX.VideoRecorder.buttonSave=BX.create("span",{props:{className:"webform-button webform-button-accept webform-button-rounded webform-button-text-white"},style:{display:"none"},text:BX.message("BLOG_VIDEO_RECORD_USE_BUTTON"),events:{click:function(){if(BX.VideoRecorder.activeFormID){BX.fireEvent(BX("bx-b-uploadfile-"+BX.VideoRecorder.activeFormID),"click");var e=new File(BX.VideoRecorder.chunks,"videomessage-"+BX.date.format(BX.date.convertBitrixFormat(BX.message("FORMAT_DATETIME")))+".webm");e.hasTobeInserted=true;BX.onCustomEvent(window,"onAddVideoMessage",[e,BX.VideoRecorder.activeFormID]);BX.VideoRecorder.hideLayout()}}}}),BX.VideoRecorder.buttonCancel=BX.create("span",{props:{className:"webform-button-link bx-videomessage-video-button-cancel"},text:BX.message("BLOG_VIDEO_RECORD_CANCEL_BUTTON"),events:{click:function(){BX.VideoRecorder.hideLayout()}}}),BX.VideoRecorder.buttonRestart=BX.create("span",{props:{className:"webform-button webform-button-blue webform-button-rounded"},style:{display:"none"},text:BX.message("BLOG_VIDEO_RECORD_RESTART_BUTTON"),events:{click:function(){BX.VideoRecorder.restartRecord()}}}),BX.VideoRecorder.recordMark=BX.create("div",{props:{className:"bx-videomessage-record"},style:{display:"none"},html:'<span class="bx-videomessage-record-inner">'+BX.message("BLOG_VIDEO_RECORD_IN_PROGRESS_LABEL")+"</span>"}),BX.VideoRecorder.analyzerElement=BX.create("canvas",{props:{className:"bx-videomessage-analyzer"}})]})]})]})]});BX.VideoRecorder.popupRecord=new BX.PopupWindow("bx-popup-videomessage-record",null,{zIndex:300,autoHide:false,closeByEsc:false,overlay:true,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:function(){BX.VideoRecorder.popupRecord=null}},content:BX.VideoRecorder.layout,height:BX.VideoRecorder.getScreenHeight(),width:BX.VideoRecorder.getScreenWidth(),noAllPaddings:true});BX.VideoRecorder.popupRecord.show();BX.VideoRecorder.popupRecord.enterFullScreen();BX.VideoRecorder.outputVideo.volume=0;BX.VideoRecorder.canvasContext=BX.VideoRecorder.analyzerElement.getContext("2d");BX.VideoRecorder.canvasContext.imageSmoothingEnabled=false;BX.VideoRecorder.canvasContext.webkitImageSmoothingEnabled=false},beforeRecord:function(){window.addEventListener("resize",BX.VideoRecorder.resize);BX.VideoRecorder.startCount=5;BX.addClass(BX.VideoRecorder.startTimer,"started");BX.VideoRecorder.attachAnalyzer();BX.VideoRecorder.renderAnalyzer();BX.show(BX.VideoRecorder.analyzerElement,"inline-block");var e=function(){clearTimeout(BX.VideoRecorder.startTimeout);BX.VideoRecorder.startTimer.innerText=BX.VideoRecorder.startCount;BX.VideoRecorder.startTimeout=setTimeout(function(){BX.VideoRecorder.startCount=BX.VideoRecorder.startCount-1;if(BX.VideoRecorder.startCount===0){BX.removeClass(BX.VideoRecorder.startTimer,"started");BX.VideoRecorder.startRecord()}else{e()}},1e3)};e()},startRecord:function(){BX.VideoRecorder.chunks=[];BX.VideoRecorder.videoOverlay.style.display="none";var e={mimeType:"video/webm;codecs=vp8"};if(!MediaRecorder.isTypeSupported(e.mimeType)){e={mimeType:"video/webm;codecs=vp9"};if(!MediaRecorder.isTypeSupported(e.mimeType)){e={mimeType:"video/webm"}}}try{BX.VideoRecorder.recorder=new MediaRecorder(BX.VideoRecorder.stream,e)}catch(e){BX.VideoRecorder.showMessage(BX.message("BLOG_VIDEO_RECORD_REQUIREMENTS"),[],BX.message("BLOG_VIDEO_RECORD_REQUIREMENTS_TITLE"));BX.VideoRecorder.hideLayout();return}BX.VideoRecorder.recorder.start(BX.VideoRecorder.recorderInterval);BX.VideoRecorder.recordSize=0;BX.VideoRecorder.recordLength=0;BX.VideoRecorder.recorder.ondataavailable=function(e){BX.VideoRecorder.recordSize+=e.data.size;BX.VideoRecorder.recordLength+=BX.VideoRecorder.recorderInterval/1e3;BX.VideoRecorder.chunks.push(e.data);if(BX.VideoRecorder.isTimeToShowTransformationAlert()){BX.VideoRecorder.startTransformationCounter()}};BX.VideoRecorder.recorder.onstop=function(){BX.VideoRecorder.hideTransformTimer();BX.VideoRecorder.recordBlob=new Blob(BX.VideoRecorder.chunks,{type:"video/webm"});BX.VideoRecorder.outputVideo.src=URL.createObjectURL(BX.VideoRecorder.recordBlob);BX.VideoRecorder.state="idle";BX.VideoRecorder.buttonPlay.style.display="block";BX.VideoRecorder.buttonSave.style.display="inline-block";BX.VideoRecorder.buttonCancel.style.display="inline-block";BX.VideoRecorder.buttonRestart.style.display="inline-block"};BX.VideoRecorder.setVideoSrc(BX.VideoRecorder.stream);BX.VideoRecorder.outputVideo.volume=0;BX.VideoRecorder.outputVideo.play();BX.VideoRecorder.state="recording";BX.show(BX.VideoRecorder.recordMark,"inline-block");BX.VideoRecorder.recordInterval=setInterval(function(){BX.VideoRecorder.recordCount++;BX.VideoRecorder.recordTimer.innerText=BX.VideoRecorder.getTimeString(BX.VideoRecorder.recordCount)},1e3)},attachAnalyzer:function(){BX.VideoRecorder.audioContext=new(window.AudioContext||window.webkitAudioContext);BX.VideoRecorder.analyserNode=BX.VideoRecorder.audioContext.createAnalyser();BX.VideoRecorder.analyserNode.fftSize=128;BX.VideoRecorder.analyserNode.minDecibels=-80;BX.VideoRecorder.analyserNode.maxDecibels=-10;BX.VideoRecorder.mediaStreamNode=BX.VideoRecorder.audioContext.createMediaStreamSource(BX.VideoRecorder.stream);BX.VideoRecorder.mediaStreamNode.connect(BX.VideoRecorder.analyserNode);BX.VideoRecorder.frequencyData=new Uint8Array(BX.VideoRecorder.analyserNode.frequencyBinCount);BX.VideoRecorder.lastFrameDate=(new Date).getTime()},renderAnalyzer:function(){if(!BX.VideoRecorder.analyzerElement){return}window.requestAnimationFrame(BX.VideoRecorder.renderAnalyzer.bind(BX.VideoRecorder));var e=(new Date).getTime();if(e-BX.VideoRecorder.lastFrameDate<50){return}BX.VideoRecorder.lastFrameDate=e;BX.VideoRecorder.analyserNode.getByteFrequencyData(BX.VideoRecorder.frequencyData);var o=BX.VideoRecorder.analyzerElement.width;var r=BX.VideoRecorder.analyzerElement.height;var d=BX.VideoRecorder.analyserNode.frequencyBinCount;BX.VideoRecorder.canvasContext.clearRect(0,0,o,r);BX.VideoRecorder.canvasContext.beginPath();var i=2;var t;var n=0;var c=Math.ceil(o/2);BX.VideoRecorder.canvasContext.fillStyle="#afb2b7";for(var a=0;a<d;a++){t=Math.round(BX.VideoRecorder.frequencyData[a]*r/256);if(t<3)t=3;n=c+(i+2)*a;BX.VideoRecorder.canvasContext.fillRect(n,(r-t)/2,i,t);n=c-(i+2)*a;BX.VideoRecorder.canvasContext.fillRect(n,(r-t)/2,i,t)}BX.VideoRecorder.canvasContext.closePath()},getTimeString:function(e){var o="";var r=Math.floor(e/60);if(r<10){o="0"}o=o+r+":";e=e-r*60;if(e<10){o=o+"0"}o=o+e;return o},start:function(e){BX.VideoRecorder.transformLimit=BX.message("DISK_VIDEO_TRANSFORMATION_LIMIT")||0;BX.VideoRecorder.activeFormID=e;if(!BX.VideoRecorder.isAvailable(true)){var o="BLOG_VIDEO_RECORD_REQUIREMENTS";if(BX.VideoRecorder.errorCode){o=BX.VideoRecorder.errorCode}BX.VideoRecorder.showMessage(BX.message(o),[],BX.message("BLOG_VIDEO_RECORD_REQUIREMENTS_TITLE"))}else if(BX.VideoRecorder.isPermissionsAsked()){BX.VideoRecorder.askDevicePermission();BX.VideoRecorder.showLayout()}else{BX.VideoRecorder.showMessage(BX.message("BLOG_VIDEO_RECORD_ASK_PERMISSIONS"),[new BX.PopupWindowButton({text:BX.message("BLOG_VIDEO_RECORD_AGREE"),className:"popup-window-button-blue",events:{click:function(){BX.VideoRecorder.popupPermissionsShown=true;BX.VideoRecorder.askDevicePermission();BX.VideoRecorder.showLayout()}}}),new BX.PopupWindowButtonLink({text:BX.message("BLOG_VIDEO_RECORD_CLOSE"),className:"popup-window-button-decline",events:{click:function(){this.popupWindow.close()}}})],BX.message("BLOG_VIDEO_RECORD_PERMISSIONS_TITLE"))}},askDevicePermission:function(){navigator.mediaDevices.getUserMedia(BX.VideoRecorder.constraints).then(function(e){BX.VideoRecorder.stream=e;if(BX.VideoRecorder.popupConfirm){BX.VideoRecorder.popupConfirm.destroy()}if(!BX.VideoRecorder.popupRecord){BX.VideoRecorder.hideLayout();return}BX.VideoRecorder.setVideoSrc(BX.VideoRecorder.stream);BX.VideoRecorder.outputVideo.play()}).catch(function(e){BX.VideoRecorder.hideLayout();BX.VideoRecorder.showMessage(BX.message("BLOG_VIDEO_RECORD_PERMISSIONS_ERROR"),[],BX.message("BLOG_VIDEO_RECORD_PERMISSIONS_ERROR_TITLE"));BX.VideoRecorder.popupPermissionsShown=false;console.log(e)})},showMessage:function(e,o,r){var d=false;var r=r||"";if(typeof o=="undefined"||typeof o=="object"&&o.length<=0){o=[new BX.PopupWindowButton({text:BX.message("BLOG_VIDEO_RECORD_CLOSE"),className:"popup-window-button-blue",events:{click:function(e){this.popupWindow.close();BX.PreventDefault(e)}}})];d=true}if(this.popupConfirm!=null){this.popupConfirm.destroy()}this.popupConfirm=new BX.PopupWindow("bx-popup-videomessage-popup",null,{zIndex:200,autoHide:d,closeByEsc:d,buttons:o,overlay:true,events:{onPopupClose:function(){this.destroy()},onPopupDestroy:BX.delegate(function(){this.popupConfirm=null},this)},content:e,titleBar:r,contentColor:"white",className:"bx-popup-videomessage-popup"});this.popupConfirm.show()},hideLayout:function(){if(BX.VideoRecorder.recorder&&BX.VideoRecorder.recorder.state==="recording"){BX.VideoRecorder.recorder.stop()}if(BX.VideoRecorder.outputVideo){BX.VideoRecorder.outputVideo.pause()}if(document.cancelFullScreen){document.cancelFullScreen()}else if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}if(BX.VideoRecorder.popupRecord){BX.VideoRecorder.popupRecord.destroy()}if(BX.VideoRecorder.layout){BX.VideoRecorder.layout.remove();BX.VideoRecorder.layout=null;BX.VideoRecorder.analyzerElement=null}if(BX.VideoRecorder.stream){BX.VideoRecorder.stream.getVideoTracks().forEach(function(e){e.stop()});BX.VideoRecorder.stream.getAudioTracks().forEach(function(e){e.stop()})}BX.VideoRecorder.startCount=0;clearInterval(BX.VideoRecorder.recordInterval);BX.VideoRecorder.panel.style.display="none";BX.VideoRecorder.waterMark.style.display="none";BX.VideoRecorder.buttonPlay.style.display="none";window.removeEventListener("resize",BX.VideoRecorder.resize);BX.VideoRecorder.unlockScroll();BX.VideoRecorder.hideTransformTimer()},resize:function(){if(!BX.VideoRecorder.popupRecord){return}var e=BX.VideoRecorder.getScreenHeight();var o=BX.VideoRecorder.getScreenWidth();var r=o/e;var d=BX.VideoRecorder.outputVideo.videoWidth/BX.VideoRecorder.outputVideo.videoHeight;if(r>d){BX.VideoRecorder.outputVideo.width=o;BX.VideoRecorder.outputVideo.height=e*r/d;BX.VideoRecorder.outputVideo.style.marginTop=(e-e*r/d)/2+"px";BX.VideoRecorder.outputVideo.style.marginLeft=0}else{BX.VideoRecorder.outputVideo.height=e;BX.VideoRecorder.outputVideo.width=o*d/r;BX.VideoRecorder.outputVideo.style.marginTop=0;BX.VideoRecorder.outputVideo.style.marginLeft=(o-o*d/r)/2+"px"}BX.VideoRecorder.videoOverlay.style.height=e+"px";BX.VideoRecorder.videoContainer.style.height=e+"px";BX.VideoRecorder.popupRecord.setHeight(e);BX.VideoRecorder.videoWrap.style.height=e+"px";BX.VideoRecorder.videoWrap.style.width=BX.VideoRecorder.outputVideo.clientWidth+"px";BX.VideoRecorder.panel.style.width=o+"px";BX("popup-window-content-bx-popup-videomessage-record").style.width=o+"px";BX.VideoRecorder.panel.style.display="block";BX.VideoRecorder.waterMark.style.display="block"},lockScroll:function(){BX.addClass(document.body,"bx-videomessage-lock-scroll")},unlockScroll:function(){BX.removeClass(document.body,"bx-videomessage-lock-scroll")},setVideoSrc:function(e){if(BX.VideoRecorder.outputVideo.srcObject){BX.VideoRecorder.outputVideo.srcObject=e}else{BX.VideoRecorder.outputVideo.src=URL.createObjectURL(e)}},isTimeToShowTransformationAlert:function(){if(BX.VideoRecorder.transformLimit>0&&!BX.VideoRecorder.transformTimerShown){var e=BX.VideoRecorder.recordSize/BX.VideoRecorder.recordLength;BX.VideoRecorder.transformTimeLeft=Math.floor((BX.VideoRecorder.transformLimit-BX.VideoRecorder.recordSize)/e);if(BX.VideoRecorder.transformTimeLeft<=BX.VideoRecorder.transformTime){if(BX.VideoRecorder.transformTimeLeft>10){BX.VideoRecorder.transformTimeLeft-=10}return true}}return false},startTransformationCounter:function(){if(!BX.VideoRecorder.transformTimerShown){BX.VideoRecorder.transformTimerShown=true;BX.VideoRecorder.showTransformTimer();BX.VideoRecorder.transformTimer=setTimeout(function(){BX.VideoRecorder.hideTransformTimer()},BX.VideoRecorder.transformTimeLeft*1e3)}},showTransformTimer:function(){BX.VideoRecorder.transformTimeContainer.classList.add("js-videomessage-transform-time-active")},hideTransformTimer:function(){BX.VideoRecorder.transformTimeContainer.classList.remove("js-videomessage-transform-time-active")},restartRecord:function(){BX.VideoRecorder.recordCount=0;BX.VideoRecorder.recordTimer.innerText=BX.VideoRecorder.getTimeString(BX.VideoRecorder.recordCount);BX.VideoRecorder.startCount=5;BX.VideoRecorder.state="idle";BX.VideoRecorder.transformTimeLeft=BX.VideoRecorder.transformTime;BX.VideoRecorder.transformTimerShown=false;BX.VideoRecorder.hideTransformTimer();BX.VideoRecorder.buttonStop.style.display="inline-block";BX.VideoRecorder.buttonPlay.style.display="none";BX.VideoRecorder.buttonSave.style.display="none";BX.VideoRecorder.buttonCancel.style.display="none";BX.VideoRecorder.buttonRestart.style.display="none";BX.VideoRecorder.videoOverlay.style.display="block";if(BX.VideoRecorder.stream){BX.VideoRecorder.setVideoSrc(BX.VideoRecorder.stream);BX.VideoRecorder.outputVideo.play()}else{BX.VideoRecorder.askDevicePermission()}}};BX.addCustomEvent(window,"onInitialized",function(e){BX.VideoRecorder.bindEvents(e)})})();