|
|
Search Tutorials
This is gonna be a short writing on the Video Capabilities of Flash Player 7! The two Classes (Actionscript 2.0) that make it possible in this verison are: 1. Camera Class The Camera class is primarily for use with Macromedia Flash Communication Server, but can be used in a limited fashion without the server and that is exactly what we are gonna do! Make a limited verison Flash Movie that can capture the video of a User who has a Web Cam attached to their PC. For example, to monitor a video feed from a web camera attached to your local system. Here is a how the story goes! We will do it "The Flash MX 2004 Way!". The package available with this tutorial contains three files: Project File: wwinc_cam.flp Project File: The .AS Actionscript Class File: For example, if you are developing an invoice-tracking system, you could create an invoice class that defines all the methods and properties that each invoice should have. You would then use the new invoice() command to create invoice objects i.e.: var MyInvoice = new invoice(); The name of the class must be the same as the name of the external file that contains the class. For example, if you name a class MyVideoPlayer, the file that defines the class must be named MyVideoPlayer.as. Going into the depth of class definitions is beyond the scope of this tutorial. The MyVideoPlayer.as is our custom class file for this example. (This will also give you a hint of the Actionscript 2.0 custom class definitions). The code is well commented, so just read through it:
/******************************
Author: 123Webwizard
URL: http://webwizardinc.com/
*******************************/
class MyVideoPlayer extends Object {
private var CamObj ;
function MyVideoPlayer() { }
/*Checks to see if the camera is installed or inuse!
***************************************************/
public function hasCamera():Boolean{
if (null != Camera.get()) {
return true;
}
else {
return false;
}
}
/*our interface to the status field
***********************************/
public function setStatus(str):Void {
_root.status.text += str;
}
/*this function actually captures the video stream
**************************************************/
public function captureVideo(vo):Void {
var wwinc_Cam = Camera.get();
/*Changing the default fps*/
wwinc_Cam.setMode(280, 210, 30);
/*Ensuring 4096 bytes/sec (4K/second) to send
video with a minimum quality of 50 */
wwinc_Cam.setQuality(4096, 50);
vo.attachVideo(wwinc_Cam);
/*Video should be smoothed (interpolated) as we have scaled
the video object on the stage*/
vo.smoothing = true;
/*Exporting the Camera Object for further use*/
setCameraObject(wwinc_Cam);
}
private function setCameraObject(co){
this.CamObj = co;
}
public function getCamera():Camera{
return this.CamObj;
}
}
The .FLA Source File:
*********************
This is the Flash source file. It contains, the video object and a few calls to our own Actionscript Class (which would be next in this tutorial) i.e.:
/******************************
Author: 123Webwizard
URL: http://webwizardinc.com/
*******************************/
var wwinc_mvp = new MyVideoPlayer();
with(wwinc_mvp){
if(hasCamera()==true){
setStatus("Capturing Devices(s) found...\n");
captureVideo(myVideo_mc);
}
else{
setStatus("No display devices are installed or in use!\n");
}
}
/*Gets the status from Camera Object
************************************/
wwinc_mvp.getCamera().onStatus = function(msg) {
if (msg.code == "Camera.Muted") {
wwinc_mvp.setStatus("User has denied access to the camera!");
}
else{
with(wwinc_mvp){
setStatus("Video Device started...\n");
setStatus("Frames per second: " + getCamera().fps + "\n");
}
}
};
wwinc_mvp.getCameraObject().onActivity = function(activity) {
/*
Event handler; invoked when the camera starts or stops
detecting motion. If you want to respond to this
event handler, you must punch in your statements here!!
*/
};
Other files:
************
These two files are self explainatory! ;-)
The .SWF File: mycam.swf
the .HTML File: mycam.html
Hope it was of any use to people... I tried to give the background and all within a small time range! Have a ball!
|
||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|