Here are the full details of my finished changes to the Captions plugin. I have submitted my changes to support for their consideration in including the changes as part of the core, per Buzz:
I have modified the Caption class file (Caption.as) and made comments marking my changes within.
Here's a link to my modified file:
http://www.hirodev.com/flowplayer/Caption.as.txt
We ran across an issue with the captions plugin when we started pulling our Timed Text xml files from a Liferay Document Library. In order to retrieve the file, a dynamic URL is used that comprises of a call to a server resource (eg. /c/document_library/get_file?uuid=8cc1d1a6-a803-4a0c-8d11-b7349017366a&groupId=27265). This does not point to a static resource such as an actual file name with a file extension. Since the parseCuePoints function in the captions plugin decides how it can parse the file based upon file type, determined by the extension, these dynamic paths were rendered useless.
What I've done is to create a new public function named loadCaptionsExt that accepts 3 parameters (instead of the 2 accepted by loadCaptions): clipIndex, captionURL, and fileExtension.
The fileExtension parameter is used to pass in the extension of the caption file if the URL does not contain it. What should be passed in is the extension after the dot ("xml" instead of ".xml"). When parseCuePoints receives this value, it checks it agains the CaptionFileTypes class. Otherwise, the file extension found in the captionURL is used for evaluation.
I also modified loadCaptionFile to accept the additional fileExtension parameter, and the parseCuePoints function to add the fileExtension parameter and perform related logic if not null.
In the parseCuePoints function we first evaluate whether the fileExtension parameter is null. If not, use that as the extension value, otherwise, evaluate the captionFile string to extract the extension and compare to the CaptionFileTypes class. Instead of determining the file extension by evaluating the last 3 characters in the path, I would recommend using the lastIndexOf method to find the last "." and extract the extension from there. We want this to be flexible enough to handle varying file extension lengths. Here's an implementation example:
---------------------------------------------------------------------
var extensionIndex:Number = captionFile.lastIndexOf( '.' );
var extension:String = captionFile.substr( extensionIndex + 1, captionFile.length );
---------------------------------------------------------------------
I did not test this, so I did not implement it as a result. What I did test was the logic you see below that includes the fileExtension parameter, and so far it works on both IE and Firefox on Windows. You may choose to do more extensive testing.
An example implementation of the loadCaptionsExt function from javascript:
// In this case, we are passing in "xml" as the 3rd parameter since we are using Timed Text files. If we were using SubRip, we'd pass in "srt" instead.
// curCC is a string parameter of our dynamic URL that does not contain an actual file name.
flowplayer("player").getPlugin("captions").loadCaptionsExt(0,curCC,"xml");
I would love to see these changes implemented in the core source code for the captions plugin. This way, when the next version comes out, I won't have to modify the source code again with my changes. Also, I'm sure plenty of others will be able to benefit as well.