SeriesArticleNavigation
- Index of flex and fms3 articles
- Free video adult chat room for air and free online remote video conferencing system (jointly created by flex and fms3 ))
In the videoProgramDuring the preparation process, we often need to use the camera. before using the camera, it is necessary to check the current status of the camera:
1. Occupied
2. No camera is installed
3. Normal
See the following:Code:
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Export wedapplication xmlns: MX = "http://www.adobe.com/2006/mxml"
Layout = "absolute" creationcomplete = "Init ()">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Controls. Alert;
Private var camera: camera;
Private var isexistscamera: Boolean = false;
Private var isbusycamera: Boolean = false;
Private var intervalid: uint;
Private var times: int;
Private function Init (): void
{
Camera = camera. getcamera ();
If (CAMERA = NULL)
{
If (camera. Names. Length <= 0)
{
This. isexistscamera = false;
Alert. Show ("no camera installed ");
}
}
Else
{
This. vdpaly. attachcamera (this. Camera );
This. iscamerabusy ();
}
}
Private function iscamerabusy (): void
{
This. intervalid = setinterval (callback, 50 );
}
Private function callback (): void
{
Trace ("currentfps =" + camera. currentfps. tostring ());
If (camera. currentfps> 0)
{
// Video device available
Clearinterval (this. intervalid );
This. isbusycamera = false;
Alert. Show ("normal camera ");
}
Else
{
Times ++;
Trace ("Times =" + times. tostring ());
If (times> 30)
{
// Video Device Busy
Clearinterval (intervalid );
This. isbusycamera = true;
Alert. Show ("camera occupied ");
}
}
}
Private function Cl (): void
{
Alert. Show (this. Camera. currentfps. tostring ());
}
]>
</MX: SCRIPT>
<Mx: videodisplay id = "vdpaly" Click = "Cl ()" x = "44" Y = "64" width = "232" Height = "236"/>
</MX: Using wedapplication>
Code Description:
Camera = NULL, the camera is not installed
If the camera is occupied, the camera. currentfps is definitely not greater than 0, but equal to 0.
Favorites and sharing
Add QQ bookmarks to Baidu souzang and Yahoo favorites
RSS subscribe to me What is RSS?
Dongguan. Net Club
Welcome to join