Changeset 87c08fa30db304b89c0e17a2c94909af0474fc0e
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
reb71971
|
r87c08fa
|
|
| 37 | 37 | private var password:String; |
| 38 | 38 | private var username:String; |
| 39 | | private var accepted_license:Boolean; |
| 40 | 39 | |
| 41 | 40 | // sound |
| … |
… |
|
| 47 | 46 | private var nc:NetConnection; |
| 48 | 47 | private var ns:NetStream; |
| | 48 | |
| | 49 | // Mic VU meter |
| | 50 | private var myVu:Shape; |
| | 51 | private var vutimer:Timer; |
| 49 | 52 | |
| 50 | 53 | private function onAppInit():void |
| … |
… |
|
| 56 | 59 | username="4dc84c9279d0fcaa793eecfbc544cdbe7ea5f6e4"; |
| 57 | 60 | password="f78b64c9e0f2ea24fddce2b0d809cb2855fed1a6"; |
| 58 | | accepted_license=false; |
| 59 | 61 | uploadName=null; |
| 60 | 62 | |
| … |
… |
|
| 72 | 74 | tt.enabled=false; |
| 73 | 75 | 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 |
| 75 | 77 | return; |
| 76 | 78 | } |
| … |
… |
|
| 90 | 92 | , 'Camera Info', mx.controls.Alert.OK); |
| 91 | 93 | */ |
| 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); |
| 93 | 100 | } |
| 94 | 101 | |
| … |
… |
|
| 119 | 126 | if (soundChannel) soundChannel.stop(); |
| 120 | 127 | soundProgress.visible = false; |
| | 128 | vubox.visible = false; |
| | 129 | vutimer.stop(); |
| | 130 | myVu.graphics.clear(); |
| 121 | 131 | } |
| 122 | 132 | |
| … |
… |
|
| 143 | 153 | } |
| 144 | 154 | |
| 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 | | |
| 151 | 155 | private function startConnection():void |
| 152 | 156 | { |
| … |
… |
|
| 179 | 183 | stream.attachCamera(cam); |
| 180 | 184 | stream.attachAudio(mic); |
| | 185 | vubox.visible = true; |
| | 186 | vutimer.start(); |
| 181 | 187 | stream.publish(uploadName, "record"); |
| 182 | 188 | } |
| … |
… |
|
| 192 | 198 | public function camBt(event:Event):void { |
| 193 | 199 | if(bc.selected) { |
| 194 | | |
| 195 | | if (!accepted_license) { |
| 196 | | ask_license(); |
| 197 | | return; |
| 198 | | } |
| 199 | | |
| 200 | 200 | bp.enabled=false; |
| 201 | 201 | bu.enabled=false; |
| … |
… |
|
| 206 | 206 | br.enabled=true; |
| 207 | 207 | video.attachCamera(cam); |
| | 208 | // TODO: check if cam access is accepted! |
| 208 | 209 | bc.label="arrêter la caméra"; |
| 209 | 210 | } else { |
| … |
… |
|
| 240 | 241 | case "NetStream.Play.StreamNotFound": |
| 241 | 242 | Alert.show('error:\n'+event.info.code, 'Alert.', mx.controls.Alert.OK); |
| 242 | | break; |
| | 243 | bu.enabled=false; |
| | 244 | bp.enabled=false; |
| 243 | 245 | case "NetStream.Play.Stop": |
| 244 | 246 | bp.selected=false; |
| … |
… |
|
| 246 | 248 | break; |
| 247 | 249 | 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); |
| 249 | 251 | break; |
| 250 | 252 | } |
| … |
… |
|
| 252 | 254 | |
| 253 | 255 | public function playBt(event:Event):void { |
| 254 | | // todo: check uploadName etc |
| 255 | | // todo: disconnect camera, re-enable |
| 256 | 256 | |
| 257 | 257 | bc.selected=false; |
| … |
… |
|
| 275 | 275 | br.enabled=false; |
| 276 | 276 | |
| | 277 | if (!uploadName) return; // XXX error? NO: BUG :) |
| | 278 | |
| 277 | 279 | nc = new NetConnection(); |
| 278 | 280 | nc.connect(null); |
| 279 | 281 | ns = new NetStream(nc); |
| 280 | 282 | 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"); |
| 282 | 284 | video.mx_internal::videoPlayer.attachNetStream(ns); |
| 283 | 285 | video.mx_internal::videoPlayer.visible = true; |
| 284 | | |
| 285 | | // TODO: on end -> re-enable buttons like stop |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | private function onPubOK(event:ResultEvent):void { |
| 289 | 289 | 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 |
| 291 | 291 | bu.enabled = false; |
| 292 | 292 | } |
| … |
… |
|
| 294 | 294 | private function onPubFault(event:FaultEvent):void { |
| 295 | 295 | 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 |
| 297 | 297 | bu.enabled = false; |
| 298 | | } |
| 299 | | |
| 300 | | public function pubBt(event:Event):void { |
| 301 | | service.send({file:uploadName}); |
| 302 | 298 | } |
| 303 | 299 | |
| 304 | 300 | private function license_choise(eventObj:CloseEvent):void { |
| 305 | 301 | if (eventObj.detail==Alert.YES) { |
| 306 | | accepted_license=true; |
| 307 | | camBt(null); |
| 308 | | } else { |
| 309 | | bc.selected=false; |
| | 302 | service.send({file:uploadName}); |
| 310 | 303 | } |
| 311 | 304 | } |
| 312 | 305 | |
| 313 | 306 | private function ask_license():void { |
| | 307 | //if (!uploadName) return; // XXX error? NO: BUG :) |
| 314 | 308 | var myAlert:Alert; |
| 315 | 309 | 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.", |
| … |
… |
|
| 325 | 319 | bc.enabled=true; |
| 326 | 320 | } |
| | 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 | |
| 327 | 340 | ]]> |
| 328 | 341 | </mx:Script> |
| … |
… |
|
| 404 | 417 | <mx:VideoDisplay id="video" width="340" height="240" /> |
| 405 | 418 | <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> |
| 406 | 423 | <mx:Spacer height="100%"/> |
| | 424 | |
| | 425 | |
| 407 | 426 | <mx:Text width="340"> |
| 408 | 427 | <mx:htmlText> |
| … |
… |
|
| 413 | 432 | <mx:Text width="340"> |
| 414 | 433 | <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"/> |
| 419 | 438 | </mx:VBox> |
| 420 | 439 | </mx:Box> |