Open Source Media Framework

Getting Started in OSMF (part 3): Closed Captioning

The OSMF project I was building for my client required closed captioning. Now, back in the pre-Flex days, I had created a video mashup application in Flash that included closed captioning capabilities. For some reason, I vaguely recall that being less of a headache than the recent effort to do it in OSMF. That kind of surprised me, since there is a Closed Caption plugin available for OSMF and it comes bundled with the OSMF SVN source, in the samples directory.  Then again, maybe that’s because the recent issues I ran into are fresh in my mind whereas I barely remember that AS2 project…

Anyway, I thought it would be useful to document exactly what I had to do in order to get the closed captioning plugin, and the closed captioning sample that comes with the OSMF SVN bundle, to work.  That way maybe someone else can save a little time.

OK, first of all, you want to create a library project called CaptioningPlugin.  If you just try to import the project from the OSMF samples directly, Flash Builder wants to treat it as an Adobe AIR project.  Apparently this is the defacto standard for AS projects now, although I really don’t understand the Adobe engineers’ reasoning behind it – especially because I’m still a little confused as Adobe still seems to be hosting AIR while Flex is now under Apache.  Since I’m developing using the latest Apache Flex SDK, I’d like to make sure my projects are compiling with that SDK and not AIR, especially if the AIR version is posted by Adobe and unrelated to the Apache SDK.  From the Apache Flex site, it seems like they are bundling AIR, but they aren’t advertising any AIR version so I’m really not sure what is going on with that.

OK, anyway, create your Flex library project – I would opt to use the latest Apache Flex SDK when you set it up (it makes a difference – OSMF is now bundled with Apache Flex so you don’t need a separate OSMF swc).  Then, assuming you’ve downloaded the SVN OSMF source, you can copy everything from /OSMF/samples/CaptioningPlugin/src/ into the /src directory of your new library project.  You don’t need anything from the /bin.  In fact, the /bin has a SWF file (CaptioningPlugin.swf), not a swc – by creating your own library project you will be generating a swc that you can then use in any project where you need closed captions or subtitles.

Next, open up your new CaptioningPlugin library project in your IDE of choice.  You may find you have many errors, all of which are related to an “unknown property”, “Logging”, etc.  It’s all related to several bits of code in the source that look something like this:
CONFIG::LOGGING{
import org.osmf.logging.*;
}

Just go through all the errors and comment out those blocks.  I imagine it was in there for some debugging purpose, but you don’t need it and if you can’t compile, you won’t generate a usable library.

At this point, you should now have a usable library project that compiles – you can either reference the project directly from your projects, or you can copy the swc from the /bin directly and drop it into the /libs directory (or wherever you keep your swc files) of your project.

Next, you might want to get one or more of the closed captioning sample projects working so you can verify that your library is in fact usable.  I chose to use the one called “Captioning Sample” – there are a few different ones included in the /samples directory of the OSMF source.

So, for that project, you could probably do something like what I did above – creating a completely new project, or you could import the project.  If you import it, be prepared for some more issues.  Once you’ve imported the project, delete the OSMF swc from the /libs directly – again if you’re using the latest Flex SDK, OSMF is part of it, and if you reference an outdated OSMF swc obviously you’re going to be asking for trouble.  Next, go into the project properties and try to delete any references to hardcoded paths to your home directory.

properties for Captioning Sample project
properties for Captioning Sample project

I did that, but I still had compile errors stating that it couldn’t find a referenced directory.  I did some digging and found the reference was in the .actionScript file, but manually removing it got me nowhere – it prevented my IDE from being able to read the project at all (it started throwing java null pointer exceptions).  So I wound up doing the ugly thing, and actually manually creating the directory it was trying to reference.  Yeah, an empty set of nested folders, just to make the compiler shut up and compile.

Anyway, once I did all that, I was able to run/debug the sample project, and see the captions working.  Personally, I’d like to see ClosedCaptioning become part of the OSMF framework rather than a separate plugin – it seems like a key feature, and it also seems that plugins are maintained (or not) separately from OSMF – they might not be kept up to date or be compatible with future versions of OSMF.


Comments

Leave a Reply