Always on top Webcam

4 Comments

I’m going to be doing a video critique of some source code later on today and the people being critiqued wanted to have my mug showing so they could see the looks of incredulity (I am kidding, of course).  So I did some looking around to find something that would keep the webcam software on top of the other windows.  Turns out there’s not much there or there was some kind pay mechanism and I really didn’t want to pay money to see myself in a webcam window that stayed above the other windows.

So, me being me, I decided to use our Flash Builder for PHP IDE and write what I needed.  It’s nice and simple.  Here’s the code.

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
 xmlns:s="library://ns.adobe.com/flex/spark" 
 xmlns:mx="library://ns.adobe.com/flex/mx"
 alwaysInFront="true"
 creationComplete="initCamera()">
 <fx:Script>
 <![CDATA[
 import mx.collections.ArrayCollection;
 import mx.rpc.events.ResultEvent;
 
 protected var video : Video;
 protected var resolutions : Array = [{
 height: 480, width: 640
 },{
 height: 600, width: 800
 },{
 height: 768, width: 1024
 },{
 height: 720, width: 1280
 }
 ];
 
 protected function initCamera() : void {
 if (video) {
 videoDisplay.removeChild(video);
 }
 var camWidth : int = resolutions[cameraRes.value]["width"]; 
 var camHeight : int = resolutions[cameraRes.value]["height"]; 
 video = new Video(camWidth, camHeight);
 var camera : Camera = Camera.getCamera();
 camera.setMode(camWidth, camHeight, 30, true);
 video.attachCamera(camera);
 videoDisplay.addChild(video);
 width = camera.width;
 height = camera.height;
 }
 ]]>
 </fx:Script>
 <s:VideoDisplay x="0" y="0" width="100%" height="100%" id="videoDisplay" />
 <s:HSlider bottom="10" width="17%" change="initCamera()" horizontalCenter="-1" maximum="4"
 minimum="0" value="0" id="cameraRes"/>
</s:WindowedApplication>

Here’s the AIR file.  If you have AIR installed you can easily run it.  Here it is with a Windows installer.

4 thoughts on “Always on top Webcam

  1. It is a great software. Can you provide an option to resize and reposition the window.- say about 2 inches in the left upper corner. This would be very useful to project the speaker’s live video during a live powerpoint presentaion.

Leave a Reply

Your email address will not be published. Required fields are marked *