简体   繁体   English

使用 Flash Media Server 的网络摄像头池

[英]Webcam pool using Flash Media Server

I have an application where users can log in and connect to the Flash media server.我有一个应用程序,用户可以在其中登录并连接到 Flash 媒体服务器。 Once they have been connected, anyone can view their webcam.连接后,任何人都可以查看他们的网络摄像头。

For example, lets say Bob and Sally log on to the website and their cameras are now being streamed.例如,假设 Bob 和 Sally 登录到网站并且他们的摄像机现在正在流式传输。 Bob can view Sally's webcam stream at http://www.example.com?cam=sally and Sally can view Bob's webcam stream at http://www.example.com?cam=bob Bob可以在查看Sally的摄像头流http://www.example.com?cam=sally和Sally可以查看Bob的网络摄像头流http://www.example.com?cam=bob

Use this code to broadcast webcam stream to FMS:使用此代码将网络摄像头流广播到 FMS:

    var nc : NetConnection = new NetConnection( );
        nc.client = this;
        nc.addEventListener(NetStatusEvent.NET_STATUS, statusHandler );
        nc.connect( "rtmp://your-fms-server-url/your-application" );

    var cam : Camera = Camera.getCamera( );
        cam.setMode( 640, 480, 20 );

    var ns : NetStream;

    function statusHandler ( eventOBJ : NetStatusEvent )
    {
        if ( eventOBJ.info.code == "NetConnection.Connect.Success" )
        {
            ns = new NetStream( nc );
            ns.attachCamera( cam );
            ns.publish( "your-stream-name" );
        }
    };

The receiver is simliar, except a few lines:接收器是相似的,除了几行:

    // to the declaration section:
    var video : Video = new Video( );

    // code in the statusHandler method:
    if ( eventOBJ.info.code == "NetConnection.Connect.Success" )
    {
        ns = new NetStream( nc );
        ns.play( "your-stream-name", -1 );
        video.attachNetStream( ns );    
        addChild( video );
    }

And you simply pass the name of the desired stream in flashvars.您只需在 flashvars 中传递所需流的名称。 For example if you use this url: www.yourdomain.com/chat.php?cam=Sally, in this case pass the cam parameter to the SWF client, and use in the following form:例如,如果您使用此 url:www.yourdomain.com/chat.php?cam=Sally,在这种情况下,将 cam 参数传递给 SWF 客户端,并以以下形式使用:

    ns.play( this.loaderInfo.parameters.cam , -1 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM