Current Path : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/bitrix/js/im/call/ |
Current File : /var/www/axolotl/data/www/arhangelsk.axolotls.ru/bitrix/js/im/call/hardware.min.js |
(function(){var e=function(){this.initialized=false;this._currentDeviceList=[];this.updating=false;Object.defineProperty(this,"cameraList",{get:this._getDeviceMap.bind(this,"videoinput")});Object.defineProperty(this,"microphoneList",{get:function(){return this._getDeviceMap("audioinput")}});Object.defineProperty(this,"audioOutputList",{get:function(){return this._getDeviceMap("audiooutput")}});Object.defineProperty(this,"defaultMicrophone",{get:function(){var e=localStorage?localStorage.getItem("bx-im-settings-default-microphone"):"";return this.microphoneList[e]?e:""}});Object.defineProperty(this,"defaultCamera",{get:function(){var e=localStorage?localStorage.getItem("bx-im-settings-default-camera"):"";return this.cameraList[e]?e:""}});Object.defineProperty(this,"defaultSpeaker",{get:function(){var e=localStorage?localStorage.getItem("bx-im-settings-default-speaker"):"";return this.audioOutputList[e]?e:""}});Object.defineProperty(this,"enableMicAutoParameters",{get:function(){return localStorage?localStorage.getItem("bx-im-settings-enable-mic-auto-parameters")!=="N":true}});Object.defineProperty(this,"preferHdQuality",{get:function(){return localStorage?localStorage.getItem("bx-im-settings-camera-prefer-hd")!=="N":true}})};e.prototype={init:function(){return new Promise(function(e,t){if(this.initialized){return e()}this.enumerateDevices().then(function(t){this._currentDeviceList=t;navigator.mediaDevices.addEventListener("devicechange",BX.debounce(this.onNavigatorDeviceChanged.bind(this),500));this.initialized=true;e()}.bind(this)).catch(t)}.bind(this))},enumerateDevices:function(){return new Promise(function(e,t){if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices){return t("NO_WEBRTC")}navigator.mediaDevices.enumerateDevices().then(function(t){e(t)}.bind(this))}.bind(this))},hasCamera:function(){if(!this.initialized){throw new Error("HardwareManager is not initialized yet")}return Object.keys(this.cameraList).length>0},getMicrophoneList:function(){if(!this.initialized){throw new Error("HardwareManager is not initialized yet")}return Object.values(this._currentDeviceList).filter(function(e){return e.kind=="audioinput"})},getCameraList:function(){if(!this.initialized){throw new Error("HardwareManager is not initialized yet")}return Object.values(this._currentDeviceList).filter(function(e){return e.kind=="videoinput"})},getSpeakerList:function(){if(!this.initialized){throw new Error("HardwareManager is not initialized yet")}return Object.values(this._currentDeviceList).filter(function(e){return e.kind=="audiooutput"})},canSelectSpeaker:function(){return Object.keys(this.audioOutputList).length>0&&"setSinkId"in HTMLMediaElement.prototype},updateDeviceList:function(e){if(this.updating){return}this.updating=true;var t=this._currentDeviceList;var i=[];navigator.mediaDevices.enumerateDevices().then(function(e){e.forEach(function(e){var n=t.findIndex(function(t){return t.kind==e.kind&&t.deviceId==e.deviceId});if(n!=-1){t.splice(n,1)}else{i.push(e)}},this);BX.onCustomEvent(this,"HardwareManager::deviceChange",{added:i,removed:t});this._currentDeviceList=e;this.updating=false}.bind(this))},onNavigatorDeviceChanged:function(e){if(!this.initialized){return}this.updateDeviceList()},_getDeviceMap:function(e){var t={};if(!this.initialized){throw new Error("HardwareManager is not initialized yet")}for(var i=0;i<this._currentDeviceList.length;i++){if(this._currentDeviceList[i].kind==e){t[this._currentDeviceList[i].deviceId]=this._currentDeviceList[i].label}}return t}};BX.Call.Hardware=new e})(); //# sourceMappingURL=hardware.map.js