Header Image - charles newman's blog

Category Archives

10 Articles

Location of OSMFCCDecoder

I didn’t see any helpful information on this when I did a search so I’m posting this in case it helps anyone looking for the OSMFCCDecoder class mentioned on this page. We’ve had a few customers ask us where this class is after reading that article.

You can find it in the Adobe Media Server installation in this location (on Windows):

C:\Program Files\Adobe\Adobe Media Server 5\samples\osmfcc\OSMFCCLib

So search for Adobe Media Server and install the trial, then look in that folder for the readme.txt file that shows you how to use the code in the OSMFCCLib.swc file you’ll find in that folder.

OSMF – Loading plug-ins locally with the file:/// protocol

Some of you may already know you can load an OSMF plug-in locally using the file protocol like this:

For Mac:

file:///Users/me/Documents/dev/projects/myproject/plugins/SomeOSMFPlugin.swf

For Win:

file:///C:/dev/projects/myproject/plugins/SomeOSMFPlugin.swf

This is very handy when developing a player because you don’t need to copy your player to localhost or a Web server to run and test.

However, I just discovered this oddity:
The plug-in will fail to load if the plug-in is a release build and the player is a debug build.

The failure happens down in the OSMF 1.5 core class DynamicPluginLoader in the onSWFLoaderStateChange method on this line:

var pluginInfo:PluginInfo = root[PLUGININFO_PROPERTY_NAME] as PluginInfo;

Flash Builder clearly shows the pluginInfo property on the root variable but the pluginInfo local variable is null after the above line executes.

This is not an OSMF bug, just something that you need to be aware of. I wasted about 30 minutes on this.

Building ActionScript 3 projects with Apache Ant

There are several reasons to use Apache Ant to build your ActionScript and Adobe Flex projects:

1) If your team uses Continuos Integration.

2) Your project has lots of dependencies that have version branches of their own.

3) You don’t want to shell out the bucks for Flash Builder.

4) You want to quickly build a project without having to import the project into Flash Builder.

There are quite a few blog posts out there on how to do this, so I’ll keep this short and simple so you can get started.

To start, download the zip file here, I’ll discuss the contents of the zip below. If you are impatient or simply don’t like to read, open a Terminal window, change to the directory where you unzipped the file and type “ant”, and press Enter. The script will build the project, create ASDocs, and then create a release zip file of the built project.

If you are on Windows, you’ll need to download and install Apache Ant.  You will also need the Flex SDK installed on your system, and the location of the SDK is specified in the “build.properties” file you will find in the zip.

The Code

Rather than use a “Hello World” app, we’ll start with an OSMF-based player that is as simple as it gets. This is the bare-bones code to play a video with the OSMF (Open Source Media Framework). You’ll find a ./src and a ./libs folder in the zip. The ./libs folder contains the OSMF.swc built for Flash Player 10.1. This is the same SWC file available at osmf.org.

The ./src folder contains one ActionScript file, OSMFSimple.as:

package
{
    import flash.display.Sprite;

    import org.osmf.elements.VideoElement;
    import org.osmf.media.MediaPlayerSprite;
    import org.osmf.net.StreamingURLResource;

    [SWF(backgroundColor="0x000000", frameRate="25", width="640", height="360")]

    /**
     * This is as simple as an OSMF-based media player can get.
     **/
    public class OSMFSimple extends Sprite
    {
	private static const MEDIA:String =
            "rtmp://cp67126.edgefcs.net/ondemand/mp4:mediapm/osmf/content/test/spacealonehd_sounas_640_700.mp4";

	private var mediaPlayerSprite:MediaPlayerSprite;

	public function OSMFSimple()
	{
		mediaPlayerSprite = new MediaPlayerSprite();
		addChild(mediaPlayerSprite);

		mediaPlayerSprite.media =
                   new VideoElement(new StreamingURLResource(MEDIA));
	}
    }
}

The Ant Build Script

You will notice two files in the zip, “build.properties” and “build.xml”.

The build.properties file contains the settings that can be modified by developers to customize the build for their development environment. The idea here is: developers can tweak this file for their dev environments without having to touch the build script. This particular file contains only locale and the Flex SDK version location, but it could contain properties tied to environment variables, for example.

build.properties

#SDKLocation:
FLEX_HOME=/Applications/Adobe Flash Builder 4/sdks/4.1.0
SDK_VERSION=4.1.0.16076
LOCALE=en_US

build.xml

The build.xml file is the build script. Download the zip file and take a look at the build.xml file. You will see tasks for cleaning the bin-release folder, cleaning the deploy folder, cleaning the ASDocs folder, creating the HTML wrapper files, building the release, building the ASDocs, and creating the zip file.

Notice at the top of file, in the project tag you see default=”main”. This tells Ant to look for a task named “main”. Now look at the bottom of file and you’ll see the main task. This simply kicks off the tasks required to build a release of this project.

To run the script, simply open a Terminal window, change to the directory, type “ant” and hit enter. Because the default task is defined as “main”, no other arguments are required.

If you wanted to run a particular task, you could supply that on the command line, such as:

ant release-build

You don’t need to name your Ant script “build.xml”. If you don’t, you need to supply the filename on the command line like this:

ant -f master-build.xml

And then to specify a task within that build script:

ant -f master-build.xml release-build

Run the script by opening a Terminal window, change to the folder where you unzipped the file, and type “ant”, hit Enter.  You should see output similar to this:

charles:OSMFSimple$ ant
Buildfile: /Users/charles/Downloads/OSMFSimple/build.xml

clean:
     [echo] cleaning...

clean-deploy:
     [echo] cleaning deploy folder...

clean-asdocs:
     [echo] cleaning asdocs...

release-build:
     [echo] building...
    [mxmlc] Loading configuration file /Applications/Adobe Flash Builder 4/sdks/4.1.0/frameworks/flex-config.xml
    [mxmlc] /Users/charles/Downloads/OSMFSimple/bin-release/OSMFSimple.swf (114460 bytes)

wrapper:

build-asdocs:
     [echo] building asdocs...
    [asdoc] Loading configuration file /Applications/Adobe Flash Builder 4/sdks/4.1.0/frameworks/flex-config.xml
    [asdoc] Documentation was created in /Users/charles/Downloads/OSMFSimple/docs/

zip-deploy:
      [zip] Building zip: /Users/charles/Downloads/OSMFSimple/deploy/OSMFSimple-release.zip

main:

BUILD SUCCESSFUL
Total time: 17 seconds

If you were building a library (a SWC file) rather than a SWF, you would use the <compc> task rather than the <mxmlc> task.  For documentation on the Ant tasks supported by the Flex SDK see this page.

There are many other things you can do with Ant, such as sync with your Perforce depot, deploy to an FTP server, etc.

The only thing I haven’t figure out how to do with Ant (yet) is duplicate the “include source” check box in Flash Builder when exporting a release build. This is handy when creating sample projects. If anyone has figured this out please post a comment here.

I hope this helps you get started with ActionScript and Ant. It has made life much easier for our development team.

OSMF – Release 1.5 is now available

This release includes lots of bug fixes plus support for FMS 4.0 Multicast and FMS 3.5.3 Stream Reconnect. The stream reconnect logic will try to reconnect you to the FMS server if you switch from wired to wireless, for example. If the reconnect happens before the buffer empties, you get a seemless experience. If the buffer does empty, it will try for 2 minutes to reconnect and if successful, it will start right where it left off. Both of these new features require Flash Player 10.1.

You can get the new release at osmf.org

OSMF – Sprint 11 release now available (aka “FC1”)

Sprint 11 is the feature complete release of OSMF.  Lots of bugs were fixed for this release including the bug I mentioned in the Sprint 10 release blog post below about the MAST plugin and the SMIL plugin not working together.  In fact, in the AkamaiPluginSample all of the plugins are working nicely together.  This sample app has become the sample for demonstrating many of the OSMF plugins that reside in the OSMF repository.

For more details on this release, see this blog entry:

http://blogs.adobe.com/osmf/2010/04/osmf_fc1_released.html

OSMF – Sprint 10 release now available for download

If you’ve been waiting for OSMF (Open Source Media Framework) to settle down, now is the time to dive in. This sprint was largely about locking down the API, but we added a few features as well:

  • DVR Support. OSMF now supports DVR via Flash Media Server’s server-side DVRCast application. This feature allows clients to jump back in time while viewing a live stream.
  • Syndication support (Atom 1.0, RSS 2.0, plus iTunes and Media RSS extensions).  You’ll see a new AS3 library in OSMF that can parse all of the major feed formats, plus the media-centric RSS extensions.  I’ve also updated the Akamai Plugin Sample app to load and parse an RSS feed and display a playlist.  If you load the MAST plugin before loading the RSS feed, you get a pre-roll ad before each video in the playlist. Note there is a bug with the MAST plugin and the SMIL plugin working together, I’m hoping to address this ASAP.
  • Extended HTTP Streaming Support. OSMF now supports subclips for HTTP-streamed content, and DRM for HTTP-streamed content.

See the OSMF blog post here for more details on these features:

http://blogs.adobe.com/osmf/

As usual, if you have questions, you can post them to the OSMF forums:

http://forums.adobe.com/community/opensource/osmf/

OSMF – Sprint 9 release now available for download

The latest release of OSMF is now available here:

http://opensource.adobe.com/wiki/display/osmf/Downloads

This is the work we did for Sprint 9, which concluded on January 20th. There are quite a few changes to the API and you can read the release notes for the specific changes.  The release notes have detailed descriptions of the API changes and should ease your pain when compiling your player against this new release.

Some of the new features in this release include:

See the OSMF blog post here for more details on these features:

http://blogs.adobe.com/osmf/

We are currently heads down on Sprint 10, which will wrap up on February 24th.

As usual, if you have questions, you can post them to the OSMF forums:

http://forums.adobe.com/community/opensource/osmf/