Changeset 87c08fa30db304b89c0e17a2c94909af0474fc0e

Show
Ignore:
Timestamp:
03/06/11 16:06:12 (15 months ago)
Author:
Robin Gareus <robin@…>
Parents:
eb719711269312a77b89ba047aa0ea803a4c68d9
Children:
0f973c08b964db1275e3a7379cd46660a974b7dd
git-committer:
Robin Gareus <robin@gareus.org> / 2011-03-06T17:06:12Z+0100
Message:

sansarmes: VU meter, translate comments, etc

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • flex/sansarmes/main.mxml

    reb71971 r87c08fa  
    3737            private var password:String; 
    3838            private var username:String; 
    39             private var accepted_license:Boolean; 
    4039 
    4140            // sound 
     
    4746            private var nc:NetConnection; 
    4847            private var ns:NetStream; 
     48 
     49            // Mic VU meter 
     50            private var myVu:Shape; 
     51            private var vutimer:Timer; 
    4952 
    5053            private function onAppInit():void 
     
    5659                username="4dc84c9279d0fcaa793eecfbc544cdbe7ea5f6e4"; 
    5760                password="f78b64c9e0f2ea24fddce2b0d809cb2855fed1a6"; 
    58                 accepted_license=false; 
    5961                uploadName=null; 
    6062               
     
    7274                    tt.enabled=false; 
    7375                    Alert.show('You do need a camera for live streaming.\nPlease connect one and then reload this Page.', 
    74                                'No camera detected', mx.controls.Alert.OK); 
     76                               'No camera detected', mx.controls.Alert.OK); // XXX translate 
    7577                    return; 
    7678                } 
     
    9092                    , 'Camera Info', mx.controls.Alert.OK); 
    9193              */ 
    92  
     94              // VU 
     95                vutimer = new Timer(120); 
     96                vutimer.addEventListener(TimerEvent.TIMER, vuTimerHandler); 
     97                myVu=new Shape(); 
     98                myVu.graphics.clear(); 
     99                vucanvas.rawChildren.addChild(myVu);  
    93100            } 
    94101 
     
    119126                if (soundChannel) soundChannel.stop(); 
    120127                soundProgress.visible = false; 
     128                vubox.visible = false; 
     129                vutimer.stop(); 
     130                myVu.graphics.clear(); 
    121131            }  
    122132             
     
    143153            } 
    144154 
    145             private function onTacFault(event:FaultEvent):void 
    146             { 
    147                 Alert.show('HTTP error:\n'+event.toString(),'Alert.', mx.controls.Alert.OK); 
    148                 br.selected=false; 
    149             } 
    150              
    151155            private function startConnection():void 
    152156            { 
     
    179183                stream.attachCamera(cam); 
    180184                stream.attachAudio(mic); 
     185                vubox.visible = true; 
     186                vutimer.start(); 
    181187                stream.publish(uploadName, "record");    
    182188            } 
     
    192198            public function camBt(event:Event):void { 
    193199                if(bc.selected) { 
    194  
    195                     if (!accepted_license) { 
    196                       ask_license(); 
    197                       return; 
    198                     } 
    199  
    200200                    bp.enabled=false; 
    201201                    bu.enabled=false; 
     
    206206                    br.enabled=true; 
    207207                    video.attachCamera(cam); 
     208                    // TODO: check if cam access is accepted! 
    208209                    bc.label="arrêter la caméra"; 
    209210                } else { 
     
    240241                    case "NetStream.Play.StreamNotFound": 
    241242                        Alert.show('error:\n'+event.info.code, 'Alert.', mx.controls.Alert.OK); 
    242                         break; 
     243                        bu.enabled=false; 
     244                        bp.enabled=false; 
    243245                    case "NetStream.Play.Stop":                 
    244246                        bp.selected=false; 
     
    246248                        break; 
    247249                    default:                     
    248                         Alert.show('debug:\n'+event.info.code, 'Alert.', mx.controls.Alert.OK); 
     250                        //Alert.show('debug:\n'+event.info.code, 'Alert.', mx.controls.Alert.OK); 
    249251                        break; 
    250252                } 
     
    252254 
    253255            public function playBt(event:Event):void { 
    254                 // todo: check uploadName etc 
    255                 // todo: disconnect camera, re-enable  
    256256 
    257257                bc.selected=false; 
     
    275275                br.enabled=false; 
    276276 
     277                if (!uploadName) return; // XXX error? NO: BUG :) 
     278 
    277279                nc = new NetConnection(); 
    278280                nc.connect(null); 
    279281                ns = new NetStream(nc); 
    280282                ns.addEventListener(NetStatusEvent.NET_STATUS, playStatusHandler); 
    281                 ns.play("http://tac1.theartcollider.org/sansarmes/data/"+uploadName+".flv"); /// XXX 
     283                ns.play("http://tac1.theartcollider.org/sansarmes/data/"+uploadName+".flv"); 
    282284                video.mx_internal::videoPlayer.attachNetStream(ns); 
    283285                video.mx_internal::videoPlayer.visible = true; 
    284  
    285                 // TODO: on end -> re-enable buttons like stop 
    286286            } 
    287287 
    288288            private function onPubOK(event:ResultEvent):void { 
    289289                Alert.show('Your video entered the moderation queue and will be published after review, soon.', 
    290                            'Published.', mx.controls.Alert.OK); 
     290                           'Published.', mx.controls.Alert.OK); // XXX translate 
    291291                bu.enabled = false; 
    292292            } 
     
    294294            private function onPubFault(event:FaultEvent):void { 
    295295                Alert.show('Publication failed. please contact robin.gareus@citu.info', 
    296                            'Publication Failed.', mx.controls.Alert.OK); 
     296                           'Publication Failed.', mx.controls.Alert.OK); // XXX translate 
    297297                bu.enabled = false; 
    298             } 
    299  
    300             public function pubBt(event:Event):void { 
    301                 service.send({file:uploadName}); 
    302298            } 
    303299 
    304300            private function license_choise(eventObj:CloseEvent):void { 
    305301                if (eventObj.detail==Alert.YES) { 
    306                     accepted_license=true; 
    307                     camBt(null); 
    308                 } else { 
    309                   bc.selected=false; 
     302                    service.send({file:uploadName}); 
    310303                } 
    311304            } 
    312305 
    313306            private function ask_license():void { 
     307                //if (!uploadName) return; // XXX error? NO: BUG :) 
    314308                var myAlert:Alert; 
    315309                myAlert = Alert.show("J'autorise la diffusion de cette vidéo (si toutefois je la valide) dans le cadre du projet \"Sans Armes Citoyens\", et notamment sur le site web d'Arte Creative et dans les présentations publiques de ce site et du projet. Les auteurs et Arte Creative s'engagent à ne pas rendre publique ou utiliser à d'autres fins les coordonnées du participant.", 
     
    325319                bc.enabled=true; 
    326320            } 
     321 
     322            // VU meter 
     323            private function vuTimerHandler(event:TimerEvent):void{ 
     324                var vol:int = mic.activityLevel; 
     325                var color:int = 0xFF0000; 
     326                if (vol<1) vol=1; 
     327                if (vol>99) vol=100; 
     328                if (vol<10)      color=0x0000FF; 
     329                else if (vol>85) color=0xFF0000; 
     330                else if (vol>70) color=0xFFFF00; 
     331                else             color=0x00FF00; 
     332                myVu.graphics.clear();           
     333                myVu.graphics.beginFill(0x000000); 
     334                myVu.graphics.drawRect(0, 0, 260, 16);             
     335                myVu.graphics.beginFill(color); 
     336                myVu.graphics.drawRect(1, 1, vol*2.58, 14);             
     337                myVu.graphics.endFill(); 
     338            } 
     339 
    327340        ]]> 
    328341    </mx:Script> 
     
    404417            <mx:VideoDisplay id="video" width="340" height="240" /> 
    405418            <mx:ProgressBar width="340" mode="manual" label="%3%%" labelPlacement="center" visible="false" id="soundProgress"/> 
     419            <mx:Box direction="horizontal" visible="false" id="vubox" width="340">  
     420                <mx:Label width="70" text="Micro:" /> 
     421                <mx:Canvas id="vucanvas" width="260" height="16"/> 
     422            </mx:Box> 
    406423            <mx:Spacer height="100%"/> 
     424 
     425 
    407426            <mx:Text width="340"> 
    408427                <mx:htmlText> 
     
    413432            <mx:Text width="340"> 
    414433                <mx:htmlText> 
    415                     <![CDATA[<b>étape 6</b>: valider l'enregistrement pour publication]]> 
    416                 </mx:htmlText> 
    417             </mx:Text> 
    418             <mx:Button id="bu" click="pubBt(event)" label="publier"/> 
     434                    <![CDATA[<b>étape 6</b>: valider et autoriser l'enregistrement pour publication]]> 
     435                </mx:htmlText> 
     436            </mx:Text> 
     437            <mx:Button id="bu" click="ask_license()" label="publier"/> 
    419438        </mx:VBox> 
    420439    </mx:Box>