Blog

Latest entries from the YAY! blog...

November 30, 2007

Flex: More on WebOrb

Writing about web page http://www.themidnightcoders.com/weborb/

More on WebOrb: I emailed MidnightCoders and got an encouraging response. I was particularly interested to find out that the Flex for Java release will soon include support for RTMP. Combined with AMF3 and Spring support, this makes it a strong alternative not just to LiveCycle but also to Red5 and Wowza Media Server – the critical factor may be cost.

November 29, 2007

Flex: Video Source Switcher

I’ve just written a basic MXML component that will switch between video sources in Flex, for a streaming application. Using the Camera class it’s possible to grab a list of connected/recognised devices and use this to switch the input source. Note that switching sources like this isn’t really recommended by Adobe, but it works anyway ;-)

For this example I’m creating a basic VBox with a List component and a Video instance. The component will show a list of sources and selecting a source will trigger the switch. Initially the component will use the default source (whatever is currently selected in the player Settings dialogue) to create a new Video instance, within a UIComponent container. The List component is populated via an array that looks up the sources using Camera.names.

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="400" creationComplete="setDefaultSource()">
<mx:Script>
<![CDATA[
import flash.media.Camera;
import flash.media.Video;
import mx.events.ListEvent;
import mx.core.UIComponent;
[Bindable]
private var sourceList:Array = Camera.names;
private var videoContainer:UIComponent = new UIComponent();
private var video:Video;
private var source:Camera;
private function setDefaultSource():void
{
video = new Video(160, 120);
source = Camera.getCamera();
video.attachCamera(source);
videoContainer.addChild(video);
addChild(videoContainer);
}
private function switchSource(event:ListEvent):void
{
videoContainer.addChild(video);
source = Camera.getCamera(String(sourceListComponent.selectedIndex));
video.attachCamera(source);
}
]]>
</mx:Script>
<mx:List dataProvider="{sourceList}" id="sourceListComponent" itemClick="switchSource(event)" width="100%"></mx:List>
</mx:VBox>

Couple of things to point out – firstly, when switching devices it’s important to recreate the Video instance using addChild() and then reattach the source to that – trying to switch the input without doing this will result in a crash.

Next, notice this line in the switchSource() handler:

Camera.getCamera(String(sourceListComponent.selectedIndex));

According to the Adobe documentation, selecting a source is done by name:

public static function getCamera(name:String = null):Camera

But for some reason this won’t work. Neither will passing in the index as a number as in Flash CS3. I was only able to fix this thanks to Andrew Trice’s multi-camera example – the index has to be passed as a String, i.e. “1”, so I’m just recasting the selectedIndex of the List to a String which seems to work fine.

Now all you need to is add a Microphone object and attach this and the Video source to a NetStream object to create a switched stream. There’s no need to recreate the NetStream when switching, just recreate the Video instance as shown. Combine this component with a screen capture driver like VHScreenCapture and you have a really simple way to switch between one or more webcams and/or your desktop.

November 27, 2007

Zoho and Google Gears: offline editing

Writing about web page http://www.readwriteweb.com/archives/zoho_on_gears.php

Zoho, the online word-processor, now implements Google Gears to provide offline editing of documents within the browser.

If you’ve got Google Gears on your computer, you can download selected Zoho documents to your hard drive with just a click. The pages for those documents will then be accessible inside your browser, even with when you are not connected to the internet. Someday soon, the company says, the other Zoho apps will also be available offline as well.

Cool – although I’m still not totally convinced that there’s a great need for ‘occasionally-connected clients’ I used Zoho to write up my final year project and there was the odd time when I couldn’t access a hotspot. Now I’m using Buzzword a lot more (I prefer the interface), but an AIR version of Buzzword would be an interesting alternative.

Flex: LiveCycle Alternatives

Thanks to The Flex Show podcast last week, I was interested to hear about WebOrb, an alternative to Adobe’s LiveCycle. LiveCycle is the enterprise platform for what used to be Flex Data Services, allowing Flex applications to integrate closely with J2EE. LiveCycle ES adds a lot of powerful tools and suites to the core FDS packages and Adobe makes a free ‘Express’ server edition available, but this is limited to a single-processor. The full version costs thousands (if you can get a price – we’ve struggled to get one from Adobe UK) and I’ve seen many posts on forums from developers who find the cost of a multi-processor licence too prohibitive.

Granite and OpenAMF have been available for a while, both are free under an LGPL licence. Granite is currently at version 0.4. but it already promises some great features, including support for AMF3, EJB3, Spring and POJOs. OpenAMF is a development of AMFPHP, an older project and while it doesn’t seem to have some of the features of Granite it does support remoting and does the basics.

WebOrb is similar to Granite, except that the product family currently supports integration with a range of platforms, including .NET, Ruby On Rails, PHP and J2EE. The Java Standard Edition is available for free and provides support for AMF0, Java Beans EJBs and POJOs. There’s also a Yahoo Group for developers using WebOrb, Flex & AJAX.