1

I found a example on a blog, how its possible to use the Adobe Cirrus to develope real-time collaboration applications. I this case its a videochat client, but the thing is that the code is written to run at desktops, not mobile devices. So my question, is there any chance to run this sample code on an android device?

The sample code

<?xml version="1.0" encoding="utf-8"?>

<mx:Script>
    <![CDATA[
        import mx.core.UIComponent;
        private var nc:NetConnection;
        private var rtmfpServer:String = "rtmfp://p2p.rtmfp.net/DEVELOPER-KEY-HERE/";
        private var sendNS:NetStream;
        private var neerPeerID:String;

        private var cam:Camera;
        private var mic:Microphone;

        private function init():void {
            initCamera();
            initNetConnection();
        }

        private function initCamera():void {
            if (Camera.names.length > 0) { 
                cam = Camera.getCamera();
                my_video_display.attachCamera(cam);
            }

            if (Microphone.names.length > 0) {
                mic = Microphone.getMicrophone();
            }
        }

        private function initNetConnection():void {
            nc = new NetConnection();
            nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusEvent);
            nc.connect(rtmfpServer);
        }

        private function netStatusEvent(event:NetStatusEvent):void {
            trace('NetConnection status event (1): ' + event.info.code);
            if (event.info.code == 'NetConnection.Connect.Success') {
                neerPeerID = nc.nearID;
                farPeerId_text.text = neerPeerID;
                initSendNetStream();
                add_contact_container.visible = true;
            }
        }

        private function initSendNetStream():void {
            sendNS = new NetStream(nc, NetStream.DIRECT_CONNECTIONS);
            sendNS.addEventListener(NetStatusEvent.NET_STATUS, netStatusEvent);

            var clientObject:Object = new Object();
            clientObject.onPeerConnect = function(ns:NetStream):Boolean {return true;}

            sendNS.client = clientObject;
            sendNS.attachCamera(cam);
            sendNS.attachAudio(mic);
            sendNS.publish('video');
        }

        private function addContact():void {
            var nc2:NetConnection = new NetConnection();
            nc2.addEventListener(NetStatusEvent.NET_STATUS, function (event:NetStatusEvent):void {
                trace('NetConnection status event (2): ' + event.info.code);
                var receiveNS:NetStream = new NetStream(nc2, contact_peer_id_text.text);
                receiveNS.addEventListener(NetStatusEvent.NET_STATUS, netStatusEvent);
                receiveNS.play('video');

                var video:Video = new Video();
                video.attachNetStream(receiveNS);

                var uic:UIComponent = new UIComponent();
                uic.width = 320;
                uic.height = 240;
                uic.addChild(video);
                video_stack.addChild(uic);

                contact_peer_id_text.text = '';
            });
            nc2.connect(rtmfpServer);
        }
    ]]>
</mx:Script>

<mx:HBox id="video_stack" top="10" left="10">
    <mx:VBox>
        <mx:VideoDisplay id="my_video_display" width="320" height="240"/>
        <mx:HBox>
            <mx:TextInput width="320" id="farPeerId_text" text="Your Peer ID is loading..."/>
        </mx:HBox>
        <mx:HBox id="add_contact_container" visible="false">
            <mx:TextInput id="contact_peer_id_text" width="200"/>
            <mx:Button label="Add contact" click="{addContact();}"/>    
        </mx:HBox>
    </mx:VBox>
</mx:HBox>

Tobias Moe Thorstensen
  • 8,861
  • 16
  • 75
  • 143
  • 1
    The answer is "Yes"; although you'll most likely want to convert the MXML Components to spark components. Did you try it? And did you run into problems? If so, what problems did you run into? – JeffryHouser Jan 21 '12 at 16:05
  • Hi! So now I have turned some of the MXML components into spark components, but somehow am not allowed to use the attachCamera on my component? Any Solutions? – Tobias Moe Thorstensen Jan 23 '12 at 08:49
  • If you're getting an specific error, please edit your question to tell us the error. – JeffryHouser Jan 23 '12 at 16:19

0 Answers0