Flash production online video conferencing program

Source: Internet
Author: User
Tags addchild

Flash production online video conferencing program

Package {
Import flash. display. Sprite;
Import flash.net. NetConnection;
Import flash.net. NetStream;
Import flash. events. NetStatusEvent;
Import flash. media. Video;
Import flash. media. Camera;
Import flash. events. ActivityEvent;

Public class videoChat extends Sprite
        {
[SWF (backgroundColor = '0xdedede', frameRate = '000000', width = '000000', height = '000000')] // Set the swf parameter
Private var conn: connFcs, camera: Camera, videoIn: Video, outStream: NetStream, inStream: NetStream;
Public function videoChat ()
                {
Var url: http://www.111cn.net/flash_a/112/String= "rtmp:/test_chat"; // connection address
Var conn: connFcs = new connFcs (url); // establish a connection. This class is located at the bottom of
This. conn = conn;
Conn. addEventListener (NetStatusEvent. NET_STATUS, NetStatusEventHandel); // monitor the connection status
                }
Private function NetStatusEventHandel (event: NetStatusEvent): void
                {
Trace (event.info. code );
If (event.info. code = "NetConnection. Connect. Success") // if the connection is successful
                        {
Init (); // Initialization
PublishStream (); // publish a video
                        }
                }
Private function publishStream (): void
                {
OutStream = new NetStream (conn );
OutStream. publish ("test", "record"); // The publish parameter. "test" indicates the Video name and "record" indicates the video to be saved. If it is not saved, use "live".
OutStream. attachCamera (camera );
InVideo ();
                }
Private function inVideo (): void
{// Receives the video
InStream = new NetStream (conn );
InStream. play ("test ");
VideoIn. attachNetStream (inStream );
                }
Private function init (): void
                {
VideoIn = new Video (); // add a Video to receive
AddChild (videoIn );
                       
Camera = Camera. getCamera (); // Get the camera
If (camera! = Null) // if there is a camera, add a video to the display
                        {
Camera. addEventListener (ActivityEvent. ACTIVITY, activityHandler );
Var video: Video = new Video (camera. width * 2, camera. height * 2 );
Video. x = camera. width;
Video. y = camera. height;
Video. attachCamera (camera );
AddChild (video );
} Else {trace ("you need camera! ");}
                       
                }
Private function activityHandler (event: ActivityEvent): void
                {
Trace ('activityhandler' + event );
                }
               
        }
       
}
Import flash.net. NetConnection;
Import flash.net. ObjectEncoding;
       

Class connFcs extends NetConnection
{
Private var url: http://www.111cn.net/flash_a/112/String
Public function connFcs (url: http://www.111cn.net/flash_a/112/String)
        {
ObjectEncoding = ObjectEncoding. AMF0; // set this parameter when connecting to the fcs.
This. url = url;
Connect (url); // start the connection
        }
}
Flash production online video conferencing program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.