Author: solomax
Date: Tue Mar 11 16:57:47 2014
New Revision: 1576426

URL: http://svn.apache.org/r1576426
Log:
[OPENMEETINGS-934] Audio modes are disabled if no audio devices present in the 
system;
        Video modes are disabled if no video devices present in the system;

Modified:
    openmeetings/branches/3.0.x/WebContent/swf10/video/editRecordStreamSWF10.lzx
    
openmeetings/trunk/singlewebapp/WebContent/swf10/video/editRecordStreamSWF10.lzx

Modified: 
openmeetings/branches/3.0.x/WebContent/swf10/video/editRecordStreamSWF10.lzx
URL: 
http://svn.apache.org/viewvc/openmeetings/branches/3.0.x/WebContent/swf10/video/editRecordStreamSWF10.lzx?rev=1576426&r1=1576425&r2=1576426&view=diff
==============================================================================
--- 
openmeetings/branches/3.0.x/WebContent/swf10/video/editRecordStreamSWF10.lzx 
(original)
+++ 
openmeetings/branches/3.0.x/WebContent/swf10/video/editRecordStreamSWF10.lzx 
Tue Mar 11 16:57:47 2014
@@ -230,9 +230,9 @@
             var t:SharedObject = SharedObject.getLocal('userdata');
             var g = t.data;
             if (g==null) g = new Array();
-            g["cam"] = this.availibleCams.getValue();
-               g["mic"] = this.availibleMics.getValue();
-               g["avstored"] = this.availibleSettings.getValue();
+            g["cam"] = this.availableCams.getValue();
+               g["mic"] = this.availableMics.getValue();
+               g["avstored"] = this.availableSettings.getValue();
                g["savecamdata"] = this.holddatainSO.getValue();
                g["width"] = this.cam_default_width;
                g["height"] = this.cam_default_height;
@@ -321,20 +321,6 @@
                
                if ($debug) Debug.write("BroadcastId: ", 
this.currentClient.broadCastID);
                switch (settings){
-                       case "s":
-                               this.myvideocontainer.setAttribute("visible", 
false);
-                               break;
-                       case "vs":
-                               
videoview.broadcast(this.currentClient.broadCastID,_camera,null);
-                               this.myvideocontainer.setAttribute("visible", 
true);
-                               if(canvas.isInterview) {
-                                       
canvas.videoComp_lc.send(canvas.videoComp_lc_name, "onStartBroadcast", 
this.currentClient.broadCastID, settings);
-                               } else {
-                                       if (this.myvideocontainer.minimized) {
-                                               
this.myvideocontainer.reminimize();
-                                       }
-                               }
-                               break;
                        case "av":
                                
videoview.broadcast(this.currentClient.broadCastID,_camera,_micro);
                                this.myvideocontainer.setAttribute("visible", 
true);
@@ -395,8 +381,8 @@
                this.isRunning = true;
                
                var videoview = 
this._video.content._publisher._chatvideoinner._videostream;
-               var _micro = this.getMic(this.availibleMics.getValue());
-               var _camera = this.getCam(this.availibleCams.getValue(), 
videoview);
+               var _micro = this.getMic(this.availableMics.getValue());
+               var _camera = this.getCam(this.availableCams.getValue(), 
videoview);
                if ($debug) Debug.write(_camera, _micro);
                
                if ($debug && _camera != null) Debug.warn("_camera.muted ", 
_camera.muted);
@@ -447,132 +433,130 @@
     <labelText fontstyle="bold" labelid="758"
                           width="${ parent.width-2 }" height="30" 
multiline="true" y="20" /> 
 
-    <labelText labelid="447" fontsize="11" fontstyle="bold" 
-                       x="10" y="80" width="$once{ parent.width-20 }" />
-
-    <resetCombobox fontsize="11" name="availibleSettings" x="10" y="100" 
width="280" editable="false">
-
-        <switch>
-            <when property="$as3">
-                <passthrough>
-                    import flash.net.SharedObject;
-                </passthrough>
-            </when>
-        </switch>
-
-        <handler name="oninit">
-            <![CDATA[
-
-                if (canvas.currentRoomObject.isAudioOnly) {
-                    this.addItem(canvas.getLabelName(449),"a");
-                    this.addItem(canvas.getLabelName(451),"n");
-                } else {
-                       this.addItem(canvas.getLabelName(448),"av");
-                    this.addItem(canvas.getLabelName(449),"a");
-                    this.addItem(canvas.getLabelName(450),"v");
-                    //this.addItem(canvas.getLabelName(845),"s");
-                    //this.addItem(canvas.getLabelName(846),"sv");
-                    this.addItem(canvas.getLabelName(451),"n");
-                }
-
-                               var t:SharedObject = 
SharedObject.getLocal('userdata');
-                               var g = t.data;
-                               var cam = null;
-                               if (g!=null){
-                                       var avstored = g["avstored"];
-                               }
+    <labelText labelid="447" fontsize="11" fontstyle="bold" x="10" y="80" 
width="$once{ parent.width-20 }" />
 
-                               var tItem = this.getItem(String(avstored));
-                               if (tItem != null) {
-                                   this.selectItem(String(avstored));
-                               } else {
-                                       this.selectItemAt(0);
-                               }
-            ]]>
-        </handler>
-
-        <handler name="onselect">
-               <![CDATA[
-                       var camVisible = "visible";
-                       var micVisible = "visible";
-                       var textVisible = "hidden";
-                       switch (this.getValue()){
-                               case "av":
-                                       break;
-                               case "a":
-                                       camVisible = "hidden";
-                                       break;
-                               case "v":
-                                       micVisible = "hidden";
-                                       break;
-                               case "n":
-                                       camVisible = "hidden";
-                                       micVisible = "hidden";
-                                       textVisible = "visible";
-                                       break;
-                               default:
-                                       if ($debug) Debug.warn("no valid device 
Setup chosen");
-                                       break;
-                       }
-                
this.parent.availibleCamsLabel.setAttribute("visibility",camVisible);
-                
this.parent.availibleCams.setAttribute("visibility",camVisible);
-                
this.parent.availibleMicsLabel.setAttribute("visibility",micVisible);
-                
this.parent.availibleMics.setAttribute("visibility",micVisible);       
-                
this.parent.infoTextNoAV.setAttribute("visibility",textVisible);
-                
this.parent.availibleResolutionsLabel.setAttribute("visibility",((canvas.isInterview)
 ? 'hidden' : camVisible));
-                
this.parent.availibleResolutionsWarning.setAttribute("visibility",((canvas.isInterview)
 ? 'hidden' : camVisible));
-                
this.parent.availibleResolutions.setAttribute("visibility",((canvas.isInterview)
 ? 'hidden' : camVisible));
-               ]]>
-        </handler>
-    </resetCombobox>
+       <resetCombobox fontsize="11" name="availableSettings" x="10" y="100" 
width="280" editable="false">
+               <handler name="onselect">
+               <![CDATA[
+                       var camVisible = true;
+                       var micVisible = true;
+                       var textVisible = false;
+                       switch (this.getValue()){
+                               case "av":
+                                       break;
+                               case "a":
+                                       camVisible = false;
+                                       break;
+                               case "v":
+                                       micVisible = false;
+                                       break;
+                               case "n":
+                                       camVisible = false;
+                                       micVisible = false;
+                                       textVisible = true;
+                                       break;
+                               default:
+                                       if ($debug) Debug.warn("no valid device 
Setup chosen");
+                                       break;
+                       }
+                       this.parent.availableCamsLabel.setAttribute("visible", 
camVisible);
+                       this.parent.availableCams.setAttribute("visible", 
camVisible);
+                       this.parent.availableMicsLabel.setAttribute("visible", 
micVisible);
+                       this.parent.availableMics.setAttribute("visible", 
micVisible);
+                       this.parent.infoTextNoAV.setAttribute("visible", 
textVisible);
+                       
this.parent.availibleResolutionsLabel.setAttribute("visible", 
((canvas.isInterview) ? false : camVisible));
+                       
this.parent.availibleResolutionsWarning.setAttribute("visible", 
((canvas.isInterview) ? false : camVisible));
+                       
this.parent.availibleResolutions.setAttribute("visible", ((canvas.isInterview) 
? false : camVisible));
+               ]]>
+               </handler>
+       </resetCombobox>
     
     <attribute name="executeAttachCamera" value="false" type="boolean" />
 
+       <method name="getStoredProp" args="prop">
+               //Initialize and get eventually stored property
+               var t:SharedObject = SharedObject.getLocal('userdata');
+               var g = t.data;
+               return g != null ? "" + g[prop] : null;
+       </method>
+       
+       <method name="fillDeviceList" args="list,combo,prop">
+       <![CDATA[
+               //Initialize and get eventually stored property
+               var dev = getStoredProp(prop);
+               
+               //Get all availible devices
+               var foundStoredDev = null;
+               for (var eg = 0; eg < list.length; ++eg) {
+                       combo.addItem(list[eg], eg);
+                       var r = "" + eg;
+                       if (r == dev) {
+                               foundStoredDev = r;
+                       }
+               }
+               return foundStoredDev;
+       ]]>
+       </method>
+       
+       <method name="selectListItem" args="combo,selected,select">
+               if (selected != null) {
+                       combo.selectItem(selected);
+               } else {
+                       if (select) {
+                               combo.selectItemAt(0);
+                       }
+               }
+       </method>
+       
     <!-- 
         Initialize the default settings for cam and resolution and attach the 
camera 
         after we have made sure the values are there one time
      -->
        <method name="initItemsAndDefaultAttachCamera">
-        <![CDATA[
-            //Initialize and get eventually stored camera
-            var t:SharedObject = SharedObject.getLocal('userdata');
-            var g = t.data;
-            var cam;
-            if (g != null){
-                cam = ""+g["cam"];
-            }
-        
-            //Get all availible Cam's
-            var tw = Camera.names;
-            var r = "";
-            var foundStoredCam = null;
-            for (var eg=0;eg<tw.length;eg++){
-                this.availibleCams.addItem(tw[eg],eg);
-                r=""+eg;
-                if (r == cam) {
-                    foundStoredCam = r;
-                }
-            }
-            
-            if (foundStoredCam != null) {
-                this.availibleCams.selectItem(foundStoredCam);
-            } else {
-                if (tw.length > 0) {
-                    this.availibleCams.selectItemAt(0);
-                }
-            }
-            
-            //Initialize and set default resolutions combobox
-            if ($debug) Debug.write("myConfigSet 1 ",canvas.myConfigSet);
-            if ($debug) Debug.write("myConfigSet 2 
",canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution'));
-            if ($debug) Debug.write("myConfigSet 3 
",canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/'));
-            if ($debug) Debug.write("myConfigSet 4 
",canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/*'));
-            
-            this.executeAttachCamera = true;
-            
-            this.attachCamera();
-        ]]>
-    </method>
+       <![CDATA[
+               //fill list of Cameras
+               var cameras = Camera.names;
+               var foundStoredCam = fillDeviceList(cameras, availableCams, 
"cam");
+               selectListItem(availableCams, foundStoredCam, cameras.length > 
0);
+               
+               //fill list of Mics
+               var mics = Microphone.names;
+               var foundStoredMic = fillDeviceList(cameras, availableMics, 
"mic");
+               selectListItem(availableMics, foundStoredMic, mics.length > 0);
+
+               // settings
+               var addCams = !canvas.currentRoomObject.isAudioOnly && 
cameras.length > 0;
+               var addMics = mics.length > 0;
+               if (addCams && addMics) {
+                       availableSettings.addItem(canvas.getLabelName(448), 
"av");
+               }
+               if (addMics) {
+                       availableSettings.addItem(canvas.getLabelName(449), 
"a");
+               }
+               if (addCams) {
+                       availableSettings.addItem(canvas.getLabelName(450), 
"v");
+               }
+               availableSettings.addItem(canvas.getLabelName(451), "n");
+               
+               var avstored = getStoredProp("avstored");
+               
+               if (availableSettings.getItem(avstored) != null) {
+                       availableSettings.selectItem(avstored);
+               } else {
+                       availableSettings.selectItemAt(0);
+               }
+
+               //Initialize and set default resolutions combobox
+               if ($debug) Debug.write("myConfigSet 1 ", canvas.myConfigSet);
+               if ($debug) Debug.write("myConfigSet 2 ", 
canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution'));
+               if ($debug) Debug.write("myConfigSet 3 ", 
canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/'));
+               if ($debug) Debug.write("myConfigSet 4 ", 
canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/*'));
+               
+               this.executeAttachCamera = true;
+               
+               this.attachCamera();
+       ]]>
+       </method>
        
        <method name="attachCamera">
            <![CDATA[
@@ -596,7 +580,7 @@
                        _video.content._publisher.setAttribute("visibility", 
"visible");
                        _video.content._viewer.setAttribute("visibility", 
"hidden");
                        var videoview = 
this._video.content._publisher._chatvideoinner._videostream;
-                       var _camera = getCam(availibleCams.getValue(), 
videoview);
+                       var _camera = getCam(availableCams.getValue(), 
videoview);
                        if (_camera != null) {
                            //stop will not call clear as there is no NetStream
                                videoview._stop();
@@ -617,59 +601,15 @@
        if ($debug) Debug.write("Cleaned up videos and free resources");
        </method>
        
-    <labelText name="availibleCamsLabel" labelid="52" fontsize="11" x="10" 
y="140" width="$once{ parent.width-20 }" />
-    <resetCombobox fontsize="11" name="availibleCams" x="10" y="160" 
width="280" editable="false">
+    <labelText name="availableCamsLabel" labelid="52" fontsize="11" x="10" 
y="140" width="$once{ parent.width-20 }" />
+    <resetCombobox fontsize="11" name="availableCams" x="10" y="160" 
width="280" editable="false">
                <handler name="onselect">
                        parent.attachCamera();
                </handler>
     </resetCombobox>
 
-    <labelText name="availibleMicsLabel" labelid="53" fontsize="11"
-               x="10" y="180" width="$once{ parent.width-20 }" />
-
-    <resetCombobox fontsize="11" name="availibleMics"  x="10" y="200" 
width="280" editable="false">
-        <switch>
-            <when property="$as3">
-                <passthrough>
-                    import flash.media.Microphone;
-                    import flash.net.SharedObject;
-                </passthrough>
-            </when>
-        </switch>
-        <handler name="oninit">
-            <![CDATA[
-               //Get eventually stored mic from user settings/shared 
object/cookie
-               var t:SharedObject = SharedObject.getLocal('userdata');
-                   var g = t.data;
-                   var mic = null;
-                   if (g != null) {
-                       mic = "" + g["mic"];
-                   }
-            
-                   //Get all availible Mic's
-                   var tw = Microphone.names;
-                   var r = "";
-                   var foundStoredMic = null;
-                   for (var eg=0;eg<tw.length;eg++){
-                       r = "" + eg;
-                       this.addItem(tw[eg],eg);
-                       
-                       if (r == mic) {
-                               foundStoredMic = r;
-                       }
-                   }
-
-                if ($debug) Debug.write("Select foundStoredMic: 
",foundStoredMic);
-                if (foundStoredMic != null) {
-                       this.selectItem(foundStoredMic);
-                } else {
-                    if (tw.length > 0) {
-                       this.selectItemAt(0);
-                    }
-                }
-            ]]>
-        </handler>
-    </resetCombobox>
+    <labelText name="availableMicsLabel" labelid="53" fontsize="11" x="10" 
y="180" width="$once{ parent.width-20 }" />
+    <resetCombobox fontsize="11" name="availableMics"  x="10" y="200" 
width="280" editable="false" />
 
     <labelText name="infoTextNoAV" labelid="452" multiline="true" width="280" 
                fontsize="11" x="10" y="130" visibility="hidden" />
@@ -877,9 +817,9 @@
         <handler name="onclick">
             parent.cleanVideos();
             this.parent.storelocaldata();
-            this.parent.chosenCam = parent.availibleCams.getValue();
-            this.parent.chosenMic = parent.availibleMics.getValue();
-            this.parent.chosenSetting = parent.availibleSettings.getValue();
+            this.parent.chosenCam = parent.availableCams.getValue();
+            this.parent.chosenMic = parent.availableMics.getValue();
+            this.parent.chosenSetting = parent.availableSettings.getValue();
             this.parent.remoteMessage = new Array();
             this.parent.remoteMessage[0] = 'avsettings';
             this.parent.remoteMessage[1] = "0";
@@ -901,9 +841,9 @@
         <handler name="onclick">
             parent.cleanVideos();
                this.parent.storelocaldata();
-               this.parent.chosenCam = parent.availibleCams.getValue();
-               this.parent.chosenMic = parent.availibleMics.getValue();
-               this.parent.chosenSetting = parent.availibleSettings.getValue();
+               this.parent.chosenCam = parent.availableCams.getValue();
+               this.parent.chosenMic = parent.availableMics.getValue();
+               this.parent.chosenSetting = parent.availableSettings.getValue();
                        this.parent.remoteMessage = new Array();
                        this.parent.remoteMessage[0] = 'avsettings';
                        this.parent.remoteMessage[1] = "0";

Modified: 
openmeetings/trunk/singlewebapp/WebContent/swf10/video/editRecordStreamSWF10.lzx
URL: 
http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/WebContent/swf10/video/editRecordStreamSWF10.lzx?rev=1576426&r1=1576425&r2=1576426&view=diff
==============================================================================
--- 
openmeetings/trunk/singlewebapp/WebContent/swf10/video/editRecordStreamSWF10.lzx
 (original)
+++ 
openmeetings/trunk/singlewebapp/WebContent/swf10/video/editRecordStreamSWF10.lzx
 Tue Mar 11 16:57:47 2014
@@ -230,9 +230,9 @@
             var t:SharedObject = SharedObject.getLocal('userdata');
             var g = t.data;
             if (g==null) g = new Array();
-            g["cam"] = this.availibleCams.getValue();
-               g["mic"] = this.availibleMics.getValue();
-               g["avstored"] = this.availibleSettings.getValue();
+            g["cam"] = this.availableCams.getValue();
+               g["mic"] = this.availableMics.getValue();
+               g["avstored"] = this.availableSettings.getValue();
                g["savecamdata"] = this.holddatainSO.getValue();
                g["width"] = this.cam_default_width;
                g["height"] = this.cam_default_height;
@@ -321,20 +321,6 @@
                
                if ($debug) Debug.write("BroadcastId: ", 
this.currentClient.broadCastID);
                switch (settings){
-                       case "s":
-                               this.myvideocontainer.setAttribute("visible", 
false);
-                               break;
-                       case "vs":
-                               
videoview.broadcast(this.currentClient.broadCastID,_camera,null);
-                               this.myvideocontainer.setAttribute("visible", 
true);
-                               if(canvas.isInterview) {
-                                       
canvas.videoComp_lc.send(canvas.videoComp_lc_name, "onStartBroadcast", 
this.currentClient.broadCastID, settings);
-                               } else {
-                                       if (this.myvideocontainer.minimized) {
-                                               
this.myvideocontainer.reminimize();
-                                       }
-                               }
-                               break;
                        case "av":
                                
videoview.broadcast(this.currentClient.broadCastID,_camera,_micro);
                                this.myvideocontainer.setAttribute("visible", 
true);
@@ -395,8 +381,8 @@
                this.isRunning = true;
                
                var videoview = 
this._video.content._publisher._chatvideoinner._videostream;
-               var _micro = this.getMic(this.availibleMics.getValue());
-               var _camera = this.getCam(this.availibleCams.getValue(), 
videoview);
+               var _micro = this.getMic(this.availableMics.getValue());
+               var _camera = this.getCam(this.availableCams.getValue(), 
videoview);
                if ($debug) Debug.write(_camera, _micro);
                
                if ($debug && _camera != null) Debug.warn("_camera.muted ", 
_camera.muted);
@@ -447,132 +433,130 @@
     <labelText fontstyle="bold" labelid="758"
                           width="${ parent.width-2 }" height="30" 
multiline="true" y="20" /> 
 
-    <labelText labelid="447" fontsize="11" fontstyle="bold" 
-                       x="10" y="80" width="$once{ parent.width-20 }" />
-
-    <resetCombobox fontsize="11" name="availibleSettings" x="10" y="100" 
width="280" editable="false">
-
-        <switch>
-            <when property="$as3">
-                <passthrough>
-                    import flash.net.SharedObject;
-                </passthrough>
-            </when>
-        </switch>
-
-        <handler name="oninit">
-            <![CDATA[
-
-                if (canvas.currentRoomObject.isAudioOnly) {
-                    this.addItem(canvas.getLabelName(449),"a");
-                    this.addItem(canvas.getLabelName(451),"n");
-                } else {
-                       this.addItem(canvas.getLabelName(448),"av");
-                    this.addItem(canvas.getLabelName(449),"a");
-                    this.addItem(canvas.getLabelName(450),"v");
-                    //this.addItem(canvas.getLabelName(845),"s");
-                    //this.addItem(canvas.getLabelName(846),"sv");
-                    this.addItem(canvas.getLabelName(451),"n");
-                }
-
-                               var t:SharedObject = 
SharedObject.getLocal('userdata');
-                               var g = t.data;
-                               var cam = null;
-                               if (g!=null){
-                                       var avstored = g["avstored"];
-                               }
+    <labelText labelid="447" fontsize="11" fontstyle="bold" x="10" y="80" 
width="$once{ parent.width-20 }" />
 
-                               var tItem = this.getItem(String(avstored));
-                               if (tItem != null) {
-                                   this.selectItem(String(avstored));
-                               } else {
-                                       this.selectItemAt(0);
-                               }
-            ]]>
-        </handler>
-
-        <handler name="onselect">
-               <![CDATA[
-                       var camVisible = "visible";
-                       var micVisible = "visible";
-                       var textVisible = "hidden";
-                       switch (this.getValue()){
-                               case "av":
-                                       break;
-                               case "a":
-                                       camVisible = "hidden";
-                                       break;
-                               case "v":
-                                       micVisible = "hidden";
-                                       break;
-                               case "n":
-                                       camVisible = "hidden";
-                                       micVisible = "hidden";
-                                       textVisible = "visible";
-                                       break;
-                               default:
-                                       if ($debug) Debug.warn("no valid device 
Setup chosen");
-                                       break;
-                       }
-                
this.parent.availibleCamsLabel.setAttribute("visibility",camVisible);
-                
this.parent.availibleCams.setAttribute("visibility",camVisible);
-                
this.parent.availibleMicsLabel.setAttribute("visibility",micVisible);
-                
this.parent.availibleMics.setAttribute("visibility",micVisible);       
-                
this.parent.infoTextNoAV.setAttribute("visibility",textVisible);
-                
this.parent.availibleResolutionsLabel.setAttribute("visibility",((canvas.isInterview)
 ? 'hidden' : camVisible));
-                
this.parent.availibleResolutionsWarning.setAttribute("visibility",((canvas.isInterview)
 ? 'hidden' : camVisible));
-                
this.parent.availibleResolutions.setAttribute("visibility",((canvas.isInterview)
 ? 'hidden' : camVisible));
-               ]]>
-        </handler>
-    </resetCombobox>
+       <resetCombobox fontsize="11" name="availableSettings" x="10" y="100" 
width="280" editable="false">
+               <handler name="onselect">
+               <![CDATA[
+                       var camVisible = true;
+                       var micVisible = true;
+                       var textVisible = false;
+                       switch (this.getValue()){
+                               case "av":
+                                       break;
+                               case "a":
+                                       camVisible = false;
+                                       break;
+                               case "v":
+                                       micVisible = false;
+                                       break;
+                               case "n":
+                                       camVisible = false;
+                                       micVisible = false;
+                                       textVisible = true;
+                                       break;
+                               default:
+                                       if ($debug) Debug.warn("no valid device 
Setup chosen");
+                                       break;
+                       }
+                       this.parent.availableCamsLabel.setAttribute("visible", 
camVisible);
+                       this.parent.availableCams.setAttribute("visible", 
camVisible);
+                       this.parent.availableMicsLabel.setAttribute("visible", 
micVisible);
+                       this.parent.availableMics.setAttribute("visible", 
micVisible);
+                       this.parent.infoTextNoAV.setAttribute("visible", 
textVisible);
+                       
this.parent.availibleResolutionsLabel.setAttribute("visible", 
((canvas.isInterview) ? false : camVisible));
+                       
this.parent.availibleResolutionsWarning.setAttribute("visible", 
((canvas.isInterview) ? false : camVisible));
+                       
this.parent.availibleResolutions.setAttribute("visible", ((canvas.isInterview) 
? false : camVisible));
+               ]]>
+               </handler>
+       </resetCombobox>
     
     <attribute name="executeAttachCamera" value="false" type="boolean" />
 
+       <method name="getStoredProp" args="prop">
+               //Initialize and get eventually stored property
+               var t:SharedObject = SharedObject.getLocal('userdata');
+               var g = t.data;
+               return g != null ? "" + g[prop] : null;
+       </method>
+       
+       <method name="fillDeviceList" args="list,combo,prop">
+       <![CDATA[
+               //Initialize and get eventually stored property
+               var dev = getStoredProp(prop);
+               
+               //Get all availible devices
+               var foundStoredDev = null;
+               for (var eg = 0; eg < list.length; ++eg) {
+                       combo.addItem(list[eg], eg);
+                       var r = "" + eg;
+                       if (r == dev) {
+                               foundStoredDev = r;
+                       }
+               }
+               return foundStoredDev;
+       ]]>
+       </method>
+       
+       <method name="selectListItem" args="combo,selected,select">
+               if (selected != null) {
+                       combo.selectItem(selected);
+               } else {
+                       if (select) {
+                               combo.selectItemAt(0);
+                       }
+               }
+       </method>
+       
     <!-- 
         Initialize the default settings for cam and resolution and attach the 
camera 
         after we have made sure the values are there one time
      -->
        <method name="initItemsAndDefaultAttachCamera">
-        <![CDATA[
-            //Initialize and get eventually stored camera
-            var t:SharedObject = SharedObject.getLocal('userdata');
-            var g = t.data;
-            var cam;
-            if (g != null){
-                cam = ""+g["cam"];
-            }
-        
-            //Get all availible Cam's
-            var tw = Camera.names;
-            var r = "";
-            var foundStoredCam = null;
-            for (var eg=0;eg<tw.length;eg++){
-                this.availibleCams.addItem(tw[eg],eg);
-                r=""+eg;
-                if (r == cam) {
-                    foundStoredCam = r;
-                }
-            }
-            
-            if (foundStoredCam != null) {
-                this.availibleCams.selectItem(foundStoredCam);
-            } else {
-                if (tw.length > 0) {
-                    this.availibleCams.selectItemAt(0);
-                }
-            }
-            
-            //Initialize and set default resolutions combobox
-            if ($debug) Debug.write("myConfigSet 1 ",canvas.myConfigSet);
-            if ($debug) Debug.write("myConfigSet 2 
",canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution'));
-            if ($debug) Debug.write("myConfigSet 3 
",canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/'));
-            if ($debug) Debug.write("myConfigSet 4 
",canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/*'));
-            
-            this.executeAttachCamera = true;
-            
-            this.attachCamera();
-        ]]>
-    </method>
+       <![CDATA[
+               //fill list of Cameras
+               var cameras = Camera.names;
+               var foundStoredCam = fillDeviceList(cameras, availableCams, 
"cam");
+               selectListItem(availableCams, foundStoredCam, cameras.length > 
0);
+               
+               //fill list of Mics
+               var mics = Microphone.names;
+               var foundStoredMic = fillDeviceList(cameras, availableMics, 
"mic");
+               selectListItem(availableMics, foundStoredMic, mics.length > 0);
+
+               // settings
+               var addCams = !canvas.currentRoomObject.isAudioOnly && 
cameras.length > 0;
+               var addMics = mics.length > 0;
+               if (addCams && addMics) {
+                       availableSettings.addItem(canvas.getLabelName(448), 
"av");
+               }
+               if (addMics) {
+                       availableSettings.addItem(canvas.getLabelName(449), 
"a");
+               }
+               if (addCams) {
+                       availableSettings.addItem(canvas.getLabelName(450), 
"v");
+               }
+               availableSettings.addItem(canvas.getLabelName(451), "n");
+               
+               var avstored = getStoredProp("avstored");
+               
+               if (availableSettings.getItem(avstored) != null) {
+                       availableSettings.selectItem(avstored);
+               } else {
+                       availableSettings.selectItemAt(0);
+               }
+
+               //Initialize and set default resolutions combobox
+               if ($debug) Debug.write("myConfigSet 1 ", canvas.myConfigSet);
+               if ($debug) Debug.write("myConfigSet 2 ", 
canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution'));
+               if ($debug) Debug.write("myConfigSet 3 ", 
canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/'));
+               if ($debug) Debug.write("myConfigSet 4 ", 
canvas.myConfigSet.getPointer().xpathQuery('config/availableCameraResolutions/resolution/*'));
+               
+               this.executeAttachCamera = true;
+               
+               this.attachCamera();
+       ]]>
+       </method>
        
        <method name="attachCamera">
            <![CDATA[
@@ -596,7 +580,7 @@
                        _video.content._publisher.setAttribute("visibility", 
"visible");
                        _video.content._viewer.setAttribute("visibility", 
"hidden");
                        var videoview = 
this._video.content._publisher._chatvideoinner._videostream;
-                       var _camera = getCam(availibleCams.getValue(), 
videoview);
+                       var _camera = getCam(availableCams.getValue(), 
videoview);
                        if (_camera != null) {
                            //stop will not call clear as there is no NetStream
                                videoview._stop();
@@ -617,59 +601,15 @@
        if ($debug) Debug.write("Cleaned up videos and free resources");
        </method>
        
-    <labelText name="availibleCamsLabel" labelid="52" fontsize="11" x="10" 
y="140" width="$once{ parent.width-20 }" />
-    <resetCombobox fontsize="11" name="availibleCams" x="10" y="160" 
width="280" editable="false">
+    <labelText name="availableCamsLabel" labelid="52" fontsize="11" x="10" 
y="140" width="$once{ parent.width-20 }" />
+    <resetCombobox fontsize="11" name="availableCams" x="10" y="160" 
width="280" editable="false">
                <handler name="onselect">
                        parent.attachCamera();
                </handler>
     </resetCombobox>
 
-    <labelText name="availibleMicsLabel" labelid="53" fontsize="11"
-               x="10" y="180" width="$once{ parent.width-20 }" />
-
-    <resetCombobox fontsize="11" name="availibleMics"  x="10" y="200" 
width="280" editable="false">
-        <switch>
-            <when property="$as3">
-                <passthrough>
-                    import flash.media.Microphone;
-                    import flash.net.SharedObject;
-                </passthrough>
-            </when>
-        </switch>
-        <handler name="oninit">
-            <![CDATA[
-               //Get eventually stored mic from user settings/shared 
object/cookie
-               var t:SharedObject = SharedObject.getLocal('userdata');
-                   var g = t.data;
-                   var mic = null;
-                   if (g != null) {
-                       mic = "" + g["mic"];
-                   }
-            
-                   //Get all availible Mic's
-                   var tw = Microphone.names;
-                   var r = "";
-                   var foundStoredMic = null;
-                   for (var eg=0;eg<tw.length;eg++){
-                       r = "" + eg;
-                       this.addItem(tw[eg],eg);
-                       
-                       if (r == mic) {
-                               foundStoredMic = r;
-                       }
-                   }
-
-                if ($debug) Debug.write("Select foundStoredMic: 
",foundStoredMic);
-                if (foundStoredMic != null) {
-                       this.selectItem(foundStoredMic);
-                } else {
-                    if (tw.length > 0) {
-                       this.selectItemAt(0);
-                    }
-                }
-            ]]>
-        </handler>
-    </resetCombobox>
+    <labelText name="availableMicsLabel" labelid="53" fontsize="11" x="10" 
y="180" width="$once{ parent.width-20 }" />
+    <resetCombobox fontsize="11" name="availableMics"  x="10" y="200" 
width="280" editable="false" />
 
     <labelText name="infoTextNoAV" labelid="452" multiline="true" width="280" 
                fontsize="11" x="10" y="130" visibility="hidden" />
@@ -877,9 +817,9 @@
         <handler name="onclick">
             parent.cleanVideos();
             this.parent.storelocaldata();
-            this.parent.chosenCam = parent.availibleCams.getValue();
-            this.parent.chosenMic = parent.availibleMics.getValue();
-            this.parent.chosenSetting = parent.availibleSettings.getValue();
+            this.parent.chosenCam = parent.availableCams.getValue();
+            this.parent.chosenMic = parent.availableMics.getValue();
+            this.parent.chosenSetting = parent.availableSettings.getValue();
             this.parent.remoteMessage = new Array();
             this.parent.remoteMessage[0] = 'avsettings';
             this.parent.remoteMessage[1] = "0";
@@ -901,9 +841,9 @@
         <handler name="onclick">
             parent.cleanVideos();
                this.parent.storelocaldata();
-               this.parent.chosenCam = parent.availibleCams.getValue();
-               this.parent.chosenMic = parent.availibleMics.getValue();
-               this.parent.chosenSetting = parent.availibleSettings.getValue();
+               this.parent.chosenCam = parent.availableCams.getValue();
+               this.parent.chosenMic = parent.availableMics.getValue();
+               this.parent.chosenSetting = parent.availableSettings.getValue();
                        this.parent.remoteMessage = new Array();
                        this.parent.remoteMessage[0] = 'avsettings';
                        this.parent.remoteMessage[1] = "0";


Reply via email to