Getting Started in OSMF (part 3): Closed Captioning

Open Source Media Framework

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.

Fuad Kamal

With a background in biotechnology, Fuad began his career developing assays and cutting edge technologies around HIV research. From there he shifted into the bioinformatics arena, where he developed innovative information systems in Perl. He started playing with the Flash platform around the time Flash 4 was released, and later developed the flash interface for the Flight Information Display System (FIDS) that you see at pretty much every major airport around the world today. Fuad loves delving into new technologies and pushing technologies in novel directions. Currently he is focused on providing mobile strategy & development for the Health & Fitness markets. He is an iOS developer, teaches an Android & Kotlin college course, and is currently writing The Kotlin Book http://thekotlinbook.com. Fuad has often applied principals he learned from his study of the martial arts to mentoring others as well as taking a unique approach to problem solving. He has found that quite often, the barriers we set before us are more mental than anything else, and the key to overcoming them lies in understanding this concept.

Click Here to Leave a Comment Below

Leave a Reply:


Warning: Missing argument 2 for Jetpack_Subscriptions::comment_subscribe_init(), called in /home/abunur/webapps/anaara_blog/wp-includes/class-wp-hook.php on line 286 and defined in /home/abunur/webapps/anaara_blog/wp-content/plugins/jetpack/modules/subscriptions.php on line 602

%d bloggers like this: