I don't want to  attach my Camera to video, but to netstream. The aim is to
detect video presence on netstream. For that i have to do camera on/off
Actually I am publishing my camera live on netstream  to FMS server.
Even if i do my_video.visible = false, the video will keep  publishing as
long camera is on( capturing ).
I cant touch the netstream as i am using same stream for other things (
text, arrays, objects, audio etc). Using separate streams for separate
things is costly affair.
I think logically also that I should actually stop camera/video capturing
when users says so  instead of  toggling the visibility of  UI.

Here is my toy code, though its not commented properly, i think it is easy
to understand. I am detecting video presence by watching currentFPS of
netstream.

*<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
creationComplete="connect();">
    <mx:Script>
        <![CDATA[
        import mx.controls.Alert;
        import flash.net.NetConnection;
        import flash.net.ObjectEncoding;
        import flash.events.AsyncErrorEvent;
        import flash.events.NetStatusEvent;
        import flash.net.NetStream;
        import flash.media.Camera;

        private var nc:NetConnection;
        private var RTMP:String = "rtmp://localhost/testNet";
        private var out_ns:NetStream;
        private var in_ns:NetStream;
        private var my_cam:Camera;
        private var my_video:Video;

        private function connect():void
        {
            nc = new NetConnection();
            nc.objectEncoding = ObjectEncoding.AMF0;
            nc.client = this;
            nc.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler
);
            nc.connect( RTMP );
        }

        private function netStatusHandler( event:NetStatusEvent ):void
        {
            switch( event.info.code )
            {

                case "NetConnection.Connect.Success":
                    buildComponents();
                    break;
                default:
                Alert.show(event.info.code.toString());

                trace(event.info.code);
            }
        }

        private function createNetStream():void
        {
            out_ns = new NetStream( nc );
            out_ns.client = this;
            in_ns = new NetStream( nc );
            in_ns.client = this;

        }

        public function initMyVideo():void
        {
            my_video = new Video(230,160);
            my_video.x = 10;
            my_video.width = 230;
            my_video.height = 160;
            my_video.y = 30;
            this.rawChildren.addChild(my_video);
        }

        private function publishIt():void
        {
            my_cam = Camera.getCamera();
            out_ns.attachCamera(my_cam);
            out_ns.publish("mycam","live");
        }

        private function playIt():void
        {
            my_video.attachNetStream(in_ns);
            in_ns.play("mycam");

        }

        private function showIt():void
        {
            Alert.show(" video in:" + in_ns.currentFPS + " out:" +
out_ns.currentFPS);
        }

        private function buildComponents():void
        {
            createNetStream();
            initMyVideo();
            publishIt();
            playIt();
        }
        private function cameraOn():void
        {
            my_cam = Camera.getCamera();
        }
        private function cameraOff():void
        {
            my_cam = null;
        }

        ]]>
    </mx:Script>
    <mx:Button x="277" y="62" label="ShowCurrentFPS" click="showIt();"/>
    <mx:Button x="277" y="92" label="Camera ON" click="cameraOn();"/>
    <mx:Button x="277" y="122" label="Camera OFF" click="cameraOff();"/>

</mx:Application>*




On Jan 24, 2008 8:48 PM, Sherif Abdou <[EMAIL PROTECTED]> wrote:

>   just pass a null parameter, i think but i never use a camera class
> before
> myVideo.attatchCamera(null);
>
>
> ----- Original Message ----
> From: Tom Chiverton <[EMAIL PROTECTED]<tom.chiverton%40halliwells.com>
> >
> To: [email protected] <flexcoders%40yahoogroups.com>
> Sent: Thursday, January 24, 2008 8:48:23 AM
> Subject: Re: [flexcoders] How to turn off camera ?
>
> On Thursday 24 Jan 2008, YOGESH JADHAV wrote:
> > i mean how to stop capture
>
> Would your application just stop showing the 'I'm watching you' GUI ?
>
> --
> Tom Chiverton, who's never done anything with Camera
>
> ****************************************************
>
> This email is sent for and on behalf of Halliwells LLP.
>
> Halliwells LLP is a limited liability partnership registered in England
> and Wales under registered number OC307980 whose registered office address
> is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB.
> A list of members is available for inspection at the registered office. Any
> reference to a partner in relation to Halliwells LLP means a member of
> Halliwells LLP. Regulated by The Solicitors Regulation Authority.
>
> CONFIDENTIALITY
>
> This email is intended only for the use of the addressee named above and
> may be confidential or legally privileged. If you are not the addressee you
> must not read it and must not use any information contained in nor copy it
> nor inform any person other than Halliwells LLP or the addressee of its
> existence or contents. If you have received this email in error please
> delete it and notify Halliwells LLP IT Department on 0870 365 2500.
>
> For more information about Halliwells LLP visit www.halliwells.com.
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
> __________________________________________________________
> Looking for last minute shopping deals?
> Find them fast with Yahoo! Search.
> http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>  
>



-- 


Regards,
Yogesh

Reply via email to