Archive for March, 2007

Redirect to a different URL in GWT

Tuesday, March 13th, 2007

Here is a simple JSNI function to call from your GWT app to redirect to a different URL.

//redirect the browser to the given url
public static native void redirect(String url)/*-{
      $wnd.location = url;
  }-*/;

An example call

redirect("http://www.emgarten.com/");

Creating a Web FLV Player

Tuesday, March 13th, 2007

Converting video files to FLV files can be a great way to reduce the amount of bandwidth used to stream videos from your web site. This tutorial will take you through the basics of creating a Flash FLV player the MediaDisplay component in Flash 8 Professional.

Step 1. Create a new flash file and select Components from the Window menu (Ctrl+F7) and also Component Inspector (Alt+F7) You will need both of these toolbars to work with the MediaDisplay component.components

Step 2. Drag the MediaDisplay component off of the Components menu and onto your empty flash document. Resize it to the size you want the player to be on your page.

Step 3. Give it an instance name of “player” under properties.

Step 4. Bring up the component inspector and select the component in your flash file to get its settings. Make sure it is set to FLV and then choose the settings you want for it. Use preferred media size will limit the FLV file from becoming bigger then it originally was. With this disabled it will expand to fit the size of the player. The video length can be left at zero. The URL can be set to hardcode in a video, or it can be left blank and in the next steps we will make it dynamic.

component inspector

Step 5. In order to use the same swf file to play a number of different videos we will make the URL dynamic. Add this code to the first keyframe of your document.

player.contentPath = file;

Then add these to your Flash HTML code.

<param name=”FlashVars” value=”file=myvideo.flv”/>

and the same to the embed tag

FlashVars=”file=myvideo.flv”

A simple variation for PHP would be to set it to a parameter variable so that it could be called with

/video.php?video=myvideo.flv

by adding some simple PHP code

FlashVars=”file=<? print($_GET[”video”]); ?>”

flv player

You should now have a fully working FLV player that takes a file name from the HTML or URL and loads it into the player.