/* global APP, $, JitsiMeetJS */ import UIUtil from "../../util/UIUtil"; import UIEvents from "../../../../service/UI/UIEvents"; import languages from "../../../../service/translation/languages"; import Settings from '../../../settings/Settings'; import mediaDeviceHelper from '../../../devices/mediaDeviceHelper'; const RTCUIUtils = JitsiMeetJS.util.RTCUIHelper; var constructAudioIndicatorHtml = function() { return '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ''; }; var constructMediaSettingsHtml = function() { return '
' + '' //+ constructAudioIndicatorHtml() + '
' + '' + ' ' + '' + '' + ' ' + '' + '' + ' ' + '' + '
' + '
'; }; /** * The callback function corresponding to the openSettingsWindow parameter. * * @type {function} */ var settingsWindowCallback = null; /** * Defines all methods in connection to the Settings dialog. */ var SettingsDialog = { init(eventEmitter) { this.eventEmitter = eventEmitter; }, /** * Generate html select options for available physical devices. * @param {{ deviceId, label }[]} items available devices * @param {string} [selectedId] id of selected device * @param {boolean} permissionGranted if permission to use selected device * type is granted * @returns {string} */ _generateDevicesOptions(items, selectedId, permissionGranted) { if (!permissionGranted && items.length) { return ''; } var options = items.map(function (item) { let attrs = { value: item.deviceId }; if (item.deviceId === selectedId) { attrs.selected = 'selected'; } let attrsStr = UIUtil.attrsToString(attrs); return ``; }); if (!items.length) { options.unshift(''); } return options.join(''); }, _onLoadMediaSettings() { let localVideoPreview = document.getElementById("localVideoPreview"); RTCUIUtils.setAutoPlay(localVideoPreview, true); RTCUIUtils.setVolume(localVideoPreview, 0); let localVideo = APP.conference.getVideoStream(); if (localVideo) localVideoPreview = localVideo.attach(localVideoPreview); this.eventEmitter.addListener(UIEvents.VIDEO_STREAM_CHANGED, function(newStream) { newStream.attach(localVideoPreview); }); // DEVICES LIST JitsiMeetJS.mediaDevices.isDeviceListAvailable() .then((isDeviceListAvailable) => { if (isDeviceListAvailable && JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) { this._initializeDeviceSelectionSettings(); } }); APP.UI.eventEmitter.addListener(UIEvents.DEVICE_LIST_CHANGED, (devices) => { this._changeDevicesList(devices); }); }, /** * Initializes the device list with the current available media devices * and attaches all listeners needed for device change user * event handling. */ _initializeDeviceSelectionSettings() { this._changeDevicesList(mediaDeviceHelper.getCurrentMediaDevices()); $('#selectCamera').change(function () { let cameraDeviceId = $(this).val(); if (cameraDeviceId !== Settings.getCameraDeviceId()) { this.eventEmitter .emit(UIEvents.VIDEO_DEVICE_CHANGED, cameraDeviceId); } }); $('#selectMic').change(function () { let micDeviceId = $(this).val(); if (micDeviceId !== Settings.getMicDeviceId()) { this.eventEmitter .emit(UIEvents.AUDIO_DEVICE_CHANGED, micDeviceId); } }); $('#selectAudioOutput').change(function () { let audioOutputDeviceId = $(this).val(); if (audioOutputDeviceId !== Settings.getAudioOutputDeviceId()) { this.eventEmitter.emit( UIEvents.AUDIO_OUTPUT_DEVICE_CHANGED, audioOutputDeviceId); } }); }, /** * Sets microphone's element to select camera ID from settings. */ setSelectedCameraFromSettings () { $('#selectCamera').val(Settings.getCameraDeviceId()); }, /** * Sets audio outputs's