This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch 4.0.x
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/4.0.x by this push:
     new a1290e6  [OPENMEETINGS-1142] fallback device list retrieval is added
a1290e6 is described below

commit a1290e644095498f7b3e07f1f80d910a6074989f
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Wed Jul 25 23:17:07 2018 +0700

    [OPENMEETINGS-1142] fallback device list retrieval is added
---
 openmeetings-flash/src/main/flex/main.mxml         |  18 ++++
 .../org/apache/openmeetings/web/room/settings.js   | 120 +++++++++++----------
 2 files changed, 80 insertions(+), 58 deletions(-)

diff --git a/openmeetings-flash/src/main/flex/main.mxml 
b/openmeetings-flash/src/main/flex/main.mxml
index d17a2a9..73ca00b 100644
--- a/openmeetings-flash/src/main/flex/main.mxml
+++ b/openmeetings-flash/src/main/flex/main.mxml
@@ -131,6 +131,24 @@
                        ExternalInterface.addCallback("vidResize", vidResize);
                        switch (params.mode) {
                                case 'settings': {
+                                       
ExternalInterface.addCallback("getDevices", function ():Object {
+                                               var devices:Array = [];
+                                               for (var i = 0; i < 
Camera.names.length; ++i) {
+                                                       devices.push({
+                                                               kind: 
"videoinput"
+                                                               , label: 
Camera.names[i] || "Camera " + i
+                                                               , deviceId: 
"camDevice" + i
+                                                       });
+                                               }
+                                               for (var i = 0; i < 
Microphone.names.length; ++i) {
+                                                       devices.push({
+                                                               kind: 
"audioinput"
+                                                               , label: 
Microphone.names[i] || "Microphone " + i
+                                                               , deviceId: 
"micDevice" + i
+                                                       });
+                                               }
+                                               return devices;
+                                       });
                                        
ExternalInterface.addCallback("camChanged", function (val:int):void {
                                                selectedCam = val;
                                                video.reset();
diff --git 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js
index a7b974b..ae8e585 100644
--- 
a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js
+++ 
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/settings.js
@@ -153,68 +153,72 @@ var VideoSettings = (function() {
                
el.append(OmUtil.tmpl('#settings-option-loading'));//!settings-option-disabled
                el.iconselectmenu('refresh');
        }
+       function _fillDevices(devices) {
+               let cCount = 0, mCount = 0;
+               _load();
+               cam.find('option').remove();
+               cam.append(OmUtil.tmpl('#settings-option-disabled'));
+               mic.find('option').remove();
+               mic.append(OmUtil.tmpl('#settings-option-disabled'));
+               devices.forEach(function(device) {
+                       if ('audioinput' === device.kind) {
+                               const o = $('<option></option>').attr('value', 
mCount).text(device.label)
+                                       .data('device-id', device.deviceId);
+                               if (mCount === s.video.mic) {
+                                       o.prop('selected', true);
+                               }
+                               mic.append(o);
+                               mCount++;
+                       } else if ('videoinput' === device.kind) {
+                               const o = $('<option></option>').attr('value', 
cCount).text(device.label)
+                                       .data('device-id', device.deviceId);
+                               if (cCount === s.video.cam) {
+                                       o.prop('selected', true);
+                               }
+                               cam.append(o);
+                               cCount++;
+                       }
+               });
+               cam.iconselectmenu('refresh');
+               mic.iconselectmenu('refresh');
+               res.find('option').each(function() {
+                       const o = $(this).data();
+                       if (o.width === s.video.width && o.height === 
s.video.height) {
+                               $(this).prop('selected', true);
+                               return false;
+                       }
+               });
+               res.iconselectmenu('refresh');
+               _readValues();
+               swf.init(s.video.cam, s.video.mic
+                               , o.interview ? 320 : s.video.width, 
o.interview ? 260 : s.video.height);
+       }
        function _initDevices() {
-               if (!navigator.mediaDevices || 
!navigator.mediaDevices.enumerateDevices) {
-                       OmUtil.error('enumerateDevices() not supported.');
-                       return;
-               }
                _setLoading(cam);
                _setLoading(mic);
-               navigator.mediaDevices.getUserMedia({video:true, audio:true})
-                       .then(function(stream) {
-                               const devices = 
navigator.mediaDevices.enumerateDevices()
-                                       .then(function(devices) {
-                                               _clear(stream);
-                                               return devices;
-                                       })
-                                       .catch(function(err) {
-                                               _clear(stream);
-                                               throw err;
-                                       });
-                               return devices;
-                       })
-                       .then(function(devices) {
-                               let cCount = 0, mCount = 0;
-                               _load();
-                               cam.find('option').remove();
-                               
cam.append(OmUtil.tmpl('#settings-option-disabled'));
-                               mic.find('option').remove();
-                               
mic.append(OmUtil.tmpl('#settings-option-disabled'));
-                               devices.forEach(function(device) {
-                                       if ('audioinput' === device.kind) {
-                                               const o = 
$('<option></option>').attr('value', mCount).text(device.label)
-                                                       .data('device-id', 
device.deviceId);
-                                               if (mCount === s.video.mic) {
-                                                       o.prop('selected', 
true);
-                                               }
-                                               mic.append(o);
-                                               mCount++;
-                                       } else if ('videoinput' === 
device.kind) {
-                                               const o = 
$('<option></option>').attr('value', cCount).text(device.label)
-                                                       .data('device-id', 
device.deviceId);
-                                               if (cCount === s.video.cam) {
-                                                       o.prop('selected', 
true);
-                                               }
-                                               cam.append(o);
-                                               cCount++;
-                                       }
-                               });
-                               cam.iconselectmenu('refresh');
-                               mic.iconselectmenu('refresh');
-                               res.find('option').each(function() {
-                                       const o = $(this).data();
-                                       if (o.width === s.video.width && 
o.height === s.video.height) {
-                                               $(this).prop('selected', true);
-                                               return false;
-                                       }
+               if (!navigator.mediaDevices || 
!navigator.mediaDevices.enumerateDevices) {
+                       _fillDevices(swf.getDevices());
+               } else {
+                       navigator.mediaDevices.getUserMedia({video:true, 
audio:true})
+                               .then(function(stream) {
+                                       const devices = 
navigator.mediaDevices.enumerateDevices()
+                                               .then(function(devices) {
+                                                       _clear(stream);
+                                                       return devices;
+                                               })
+                                               .catch(function(err) {
+                                                       _clear(stream);
+                                                       throw err;
+                                               });
+                                       return devices;
+                               })
+                               .then(function(devices) {
+                                       _fillDevices(devices);
+                               })
+                               .catch(function(err) {
+                                       OmUtil.error(err);
                                });
-                               _readValues();
-                               swf.init(s.video.cam, s.video.mic
-                                               , o.interview ? 320 : 
s.video.width, o.interview ? 260 : s.video.height);
-                       })
-                       .catch(function(err) {
-                               OmUtil.error(err);
-                       });
+               }
        }
        function _initSwf() {
                _initDevices();

Reply via email to