Show
Ignore:
Timestamp:
03/10/11 15:08:36 (14 months ago)
Author:
Robin Gareus <robin@…>
Parents:
34a11f2ffe4ddf280d5b202de17a984ce81c2485
Children:
a3706cf61a210c0acbba31fc661ca48f97086fcf
git-committer:
Robin Gareus <robin@gareus.org> / 2011-03-10T16:08:36Z+0100
Message:

mcluhan: added play/publish

Location:
flex/derrick-av
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • flex/derrick-av/main.html

    r99bf52b r72fdc64  
    1818  <div style="margin: 0 auto; width:720px;"> 
    1919<!--[if !IE]> --> 
    20     <object type="application/x-shockwave-flash" data="main.swf?t=2" width="720" height="420"> 
     20    <object type="application/x-shockwave-flash" data="main.swf?t=3" width="720" height="460"> 
    2121<!-- <![endif]--> 
    2222 
    2323<!--[if IE]> 
    24       <object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="420" 
     24      <object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="640" height="460" 
    2525                        codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"> 
    2626                <param name="movie" value="main.swf" /> 
  • flex/derrick-av/main.mxml

    r2038785 r72fdc64  
    11<?xml version="1.0" encoding="iso-8859-1"?> 
    22<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    3         width="720" height="420"  
     3        width="720" height="460"  
    44        layout="absolute" 
    55        backgroundColor="#ffffff" 
     
    88        creationComplete="onAppInit()" > 
    99        
     10    <mx:HTTPService id="pubreq" resultFormat="text" 
     11                    url="http://tac1.theartcollider.org/mcluhan/publish.php" 
     12                    result="onPubOK(event)" 
     13                    fault="onPubFault(event)" 
     14                    concurrency="single" 
     15                    method="POST" /> 
     16 
    1017    <mx:Script> 
    1118        <![CDATA[ 
     
    2431            private var server:String; 
    2532            private var password:String; 
    26                         private var username:String; 
     33            private var username:String; 
     34 
     35            // video playback 
     36            private var nc:NetConnection; 
     37            private var ns:NetStream; 
    2738 
    2839                        [Bindable] 
     
    3243                        private function onAppInit():void 
    3344            { 
    34                 var argv:Object = Application.application.parameters; 
    35                 baseName=argv['name']; 
     45                //var argv:Object = Application.application.parameters; 
     46                //baseName=argv['name']; 
     47                baseName='McL'; 
    3648                server="rtmp://188.165.42.118/rec-hq"; 
    3749                username="4dc84c9279d0fcaa793eecfbc544cdbe7ea5f6e4"; 
    3850                                password="f78b64c9e0f2ea24fddce2b0d809cb2855fed1a6"; 
    3951                br.enabled=false; 
     52                bp.enabled=false; 
     53                bu.enabled = false; 
    4054                                countrycodes = new ArrayCollection( [ 
    4155{ id:'XXX', label:'Please select your country..'}, 
     
    302316                        } 
    303317 
     318            private function avdeny():void { 
     319                br.enabled=false; 
     320                bp.enabled=false; 
     321                bu.enabled=false; 
     322                bc.enabled=false; 
     323                cc.enabled=false; 
     324                ta.enabled=false; 
     325                tt.enabled=false; 
     326                te.enabled=false; 
     327                tg.enabled=false; 
     328                Alert.show('You do need a camera for live streaming.\nPlease connect one and then reload this Page. It may also be that the camera is currently in use by another application: please close that app and reload.', 
     329                           'No camera detected', mx.controls.Alert.OK); 
     330            } 
     331 
     332            private function onAvStatus(event:StatusEvent):void { 
     333                if (event.code == "Microphone.Muted"){ 
     334                    avdeny(); 
     335                } 
     336            } 
     337 
    304338                        public function myinit():void { 
    305339                cam = Camera.getCamera(); 
    306340                mic = Microphone.getMicrophone(); 
     341 
     342                Security.showSettings("2"); 
     343                mic.addEventListener(StatusEvent.STATUS, this.onAvStatus); 
     344 
    307345                if (!cam || !mic) { 
    308                         br.enabled=false; 
    309                                         bc.enabled=false; 
    310                                         cc.enabled=false; 
    311                         ta.enabled=false; 
    312                         tt.enabled=false; 
    313                         te.enabled=false; 
    314                         tg.enabled=false; 
    315                         Alert.show('You do need a camera for live streaming.\nPlease connect one and then reload this Page. It may also be that the camera is currently in use by another application: please close that app and reload.', 
    316                                    'No camera detected', mx.controls.Alert.OK); 
    317                         return 
     346                    avdeny(); 
     347                        return; 
    318348                } 
    319349                 
     
    415445                stream.close(); 
    416446                conn.close(); 
     447                bp.enabled=true; 
     448                bu.enabled=true; 
    417449            } 
    418450 
     
    425457                                        tg.enabled=false; 
    426458                                        br.enabled=true; 
     459                    bp.enabled=false; 
     460                    bu.enabled=false; 
    427461                                        video.attachCamera(cam); 
    428462                                        bc.label="Stop the Camera"; 
     
    443477                                if(br.selected) { 
    444478                                        bc.enabled=false; 
     479                    bp.enabled=false; 
     480                    bu.enabled=false; 
    445481                                        startConnection() 
    446482                                }else { 
     
    448484                                        bc.enabled=true; 
    449485                                } 
    450                         } 
     486            } 
     487 
     488            private function playStatusHandler(event:NetStatusEvent):void { 
     489                switch (event.info.code) { 
     490                    case "NetStream.Buffer.Flush": 
     491                    case "NetStream.Play.Start": 
     492                    case "NetStream.Buffer.Full": 
     493                    case "NetStream.Buffer.Empty": 
     494                    case "NetStream.Seek.Notify": 
     495                        break; 
     496                    case "NetStream.Play.StreamNotFound": 
     497                        Alert.show('error:\n'+event.info.code, 'Alert.', mx.controls.Alert.OK); 
     498                        bp.enabled=false; 
     499                        bu.enabled=false; 
     500                    case "NetStream.Play.Stop": 
     501                        bp.selected=false; 
     502                        playBt(null); 
     503                        break; 
     504                    default: 
     505                        //Alert.show('debug:\n'+event.info.code, 'Alert.', mx.controls.Alert.OK); 
     506                        break; 
     507                } 
     508            } 
     509 
     510            public function playBt(event:Event):void { 
     511 
     512                bc.selected=false; 
     513                bc.enabled=false; 
     514 
     515                if(!bp.selected) { 
     516                    if (ns) { 
     517                        ns.seek(0); ns.pause(); 
     518                    } 
     519                    video.attachCamera(null); 
     520                    video.mx_internal::videoPlayer.clear(); 
     521                    bc.enabled=true; 
     522                    br.enabled=true; 
     523                    camBt(null); 
     524                    return; 
     525                } 
     526 
     527                tt.enabled=false; 
     528                ta.enabled=false; 
     529                cc.enabled=false; 
     530                te.enabled=false; 
     531                tg.enabled=false; 
     532                br.enabled=false; 
     533 
     534                if (!uploadName) return; // XXX error? NO: BUG :) 
     535 
     536                nc = new NetConnection(); 
     537                nc.connect(null); 
     538                ns = new NetStream(nc); 
     539                ns.addEventListener(NetStatusEvent.NET_STATUS, playStatusHandler); 
     540                ns.play("http://tac1.theartcollider.org/mcluhan/data/"+uploadName+".flv"); 
     541                video.mx_internal::videoPlayer.attachNetStream(ns); 
     542                video.mx_internal::videoPlayer.visible = true; 
     543            } 
     544 
     545            private function onPubOK(event:ResultEvent):void { 
     546                Alert.show('The video was registered and is queued for moderation. If you have any questions do not hesitate to contact mcmovie@digitalrumors.net.', 'Publication successful', mx.controls.Alert.OK); 
     547                bu.enabled = false; 
     548            } 
     549 
     550            private function onPubFault(event:FaultEvent):void { 
     551                Alert.show('The request for publication failed. Please contacter mcmovie@digitalrumors.net', 
     552                           'Publication failed', mx.controls.Alert.OK); 
     553                bu.enabled = false; 
     554            } 
     555 
     556            public function pubBt(event:Event):void { 
     557                pubreq.send({file:uploadName}); 
     558            } 
    451559 
    452560        ]]> 
     
    475583        </mx:Text> 
    476584 
    477         <mx:Box direction="vertical" width="100%" height="350" id="welcome" visible="true" x="0" y="30"> 
     585        <mx:Box direction="vertical" width="100%" height="390" id="welcome" visible="true" x="0" y="30"> 
    478586                        <mx:Spacer height="100%"/> 
    479587                        <mx:Box direction="horizontal"> 
     
    498606        </mx:Box> 
    499607 
    500         <mx:Box direction="horizontal" width="100%" height="350" id="mainrec" visible="false" x="0" y="40"> 
     608        <mx:Box direction="horizontal" width="100%" height="390" id="mainrec" visible="false" x="0" y="40"> 
    501609                <mx:VBox width="330" height="100%"> 
    502610                        <mx:Text width="320"> 
     
    545653                        <mx:Text width="340"> 
    546654                                <mx:htmlText> 
    547                                         <![CDATA[<b>Step 4</b>: Start recording]]> 
     655                                        <![CDATA[<b>Step 4</b>: Record Video]]> 
    548656                                </mx:htmlText> 
    549657                        </mx:Text> 
    550658                        <mx:Button id="br" toggle="true" change="recBt(event)" label="Start Recording"/> 
     659                        <mx:Text width="340"> 
     660                                <mx:htmlText> 
     661                                        <![CDATA[<b>Step 5</b>: Verify recording]]> 
     662                                </mx:htmlText> 
     663                        </mx:Text> 
     664                        <mx:Box direction="horizontal" >  
     665                <mx:Button id="bp" toggle="true" change="playBt(event)" label="Playback"/> 
     666                <mx:Button id="bu" click="pubBt(event)" label="Publish"/> 
     667            </mx:Box> 
    551668                </mx:VBox> 
    552669        </mx:Box> 
    553670 
    554         <mx:Text width="100%" styleName="footer"  x="0" y="400">  
     671        <mx:Text width="100%" styleName="footer"  x="0" y="440">  
    555672                <mx:htmlText> 
    556673                        <![CDATA[&#169; 2011 CITU.fr, robin@gareus.org]]>