Video Conference Development and Analysis

Source: Internet
Author: User

<? XML version = "1.0" encoding = "UTF-8"?>

<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
<Mx: SCRIPT>
<! [CDATA [
Import flash. Events. netstatusevent;
Import flash.net. netconnection;

Import flash. display. Sprite;
Import flash. Media. camera;
Import flash. Media. video;
Import flash. Text. textfield;
Import MX. Controls. Alert;
Import CN. mediasky. Media .*;

Import flash. display. Sprite;
Import flash. Events .*;
Import flash. Media. Microphone;
Import flash. system. Security;
Import flash. system. securitypanel;
Import flash. Media. Microphone;
Import flash. Media. soundloadercontext;

Private var NC: netconnection;
Private var active_mic: microphone = microphone. getmicrophone ();
Private function connecthandler (): void
{

Trace ("start to connect to the service ");
NC = new netconnection ();
NC. addeventlistener (netstatusevent. net_status, netstatushandler );
NC. Connect ("rtmp: // www.resincrm.com/helloserver ");

}
Public Function closehandler (): void
{
Trace ("close connection ");
NC. Close ();
}
Public Function netstatushandler (Event: netstatusevent): void
{
Trace ("connected is:" + NC. Connected );
Trace ("event.info. Level:" + event.info. Level );
Trace ("event.info. Code:" + event.info. Code );

Switch (event.info. Code)
{
Case "netconnection. Connect. Success ":
Alert. Show ("Congratulations! You're connected "+" \ n ");
Break;
Case "netconnection. Connect. Rejected ":
Trace ("Oops! The connection was rejected "+" \ n ");
Break;
Case "netconnection. Connect. Closed ":
Trace ("thanks! The connection has been closed "+" \ n ");
Break;
}
}

Public var cam: camera;
Public Function checkcambusy (usercam: Camera): void
{
VaR chktime: Number = 0;
VaR intervalid: number;
Function callback (): void
{
If (usercam. currentfps> 0)
{
// Available devices
Clearinterval (intervalid );
}
Else
{
Chktime ++;
If (chktime> 30)
{
// The device is busy
Clearinterval (intervalid );
 
// Alert. Show ("camera occupied ");
}
}

}
Intervalid = setinterval (callback, 50 );
}
Public Function initcamera (): void {
// Initialize the variable.
Cam = camera. getcamera ();
VaR mic: microphone = microphone. getmicrophone ();
// Security. showsettings (securitypanel. Microphone );

Mic. addeventlistener (statusevent. status, this. onmicstatus );


If (mic! = NULL ){
Mic. setuseechosuppression (true );
Mic. setloopback (true); // local noise. If you do not need headphones, an echo is returned.
Mic. addeventlistener (activityevent. Activity, activityhandler );
Mic. addeventlistener (statusevent. Status, statushandler );
}
If (Cam! = NULL)
{
Cam. addeventlistener (statusevent. Status, camerastatushander );
Cam. setmode (160,120, 15 );


Myvid. attachcamera (CAM );
Checkcambusy (CAM );
}
Else
{
Alert. Show ("the camera has been used by other applications. Please close the occupied program and try again! ");
}
}
Public Function onmicstatus (Event: statusevent): void
{
If (event. Code = "microphone. unmuted ")
{
Alert. Show ("microphone accessible .");
}
Else if (event. Code = "microphone. muted ")
{
Alert. Show ("microphone access was denied .");
}
}
Public Function camerastatushander (Event: statusevent): void
{
Switch (event. Code)
{
Case "camera. muted ":
Alert. Show ("the camera user clicked reject '. ");
Break;
Case "camera. unmuted ":
Alert. Show ("the camera user clicked accept '. ");
Break;
}

}
Private function activityhandler (Event: activityevent): void {
Alert. Show ("activityhandler:" + Event );
}

Private function statushandler (Event: statusevent): void {
Alert. Show ("statushandler:" + Event );
}


]>
</MX: SCRIPT>

<Mx: button x = "10" Y = "538" label = "Connect" id = "btnconnect" Click = "connecthandler ();"/>
<Mx: button x = "108" Y = "538" label = "close" id = "btnclose" Click = "closehandler ();"/>
<Mx: Label x = "211" Y = "542" width = "109" id = "lbinfo"/>
<Mx: button x = "10" Y = "468" label = "camera" id = "btnvideo" Click = "initcamera ();"/>

 
<Mx: panel x = "10" Y = "10" width = "183" Height = "165" layout = "absolute" id = "cam1" Title = "yellow and Qing" fontfamily =" arial "fontsize =" 12 "color =" # 0b0d3c ">
<Mx: videodisplay id = "myvid" width = "160" Height = "120"
Creationcomplete = "initcamera ();" x = "0" Y = "0"/>
</MX: Panel>
 
</MX: Application>

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.