I’ve been continuing to work on the BBB player and from the list and I decided to tackle two of the items from the list that were quick-fix oversights from past releases. I’m talking about the promised features of toggling subtitles on/off and hooking dummy server calls up for the chapter addition/deletion demo. Also included is Bookmark object and API refactoring.
Hooking up dummy server calls on chapter addition/deletion
The purpose for this change was to emulate the final deployed environment from within the library. I had already hooked up a call using XmlHttpRequest to retrieve chapter data, so this one should’ve been fairly simple. Just modify the two library calls to include XHR and it would be done. Not quite. The strategy was to make the remote call, and then to add/delete it locally only if the remote call succeeded. We want to keep everything in sync, don’t we?
Turns out syncing that up highlighted an existing synchronization-related bug in the library. The printTOC() function, which prints the Table of Contents, had some weird funny business going on which resulted in the outputted rows being deleted and occasionally not repopulated. A quick fix to moving the deletion code inside the check for if the Table of Contents had been modified fixed this. Not sure why it was placed before it, but it’s fixed now.
For this to work, I had to add an optional second parameter to the addChapter() function named “updateServer”. Give it true to update the server remotely (required for saving persistent data). See the DEMO!
Toggle Subtitles On/Off
This one was really fun, what should’ve been a simple fix had me debugging a bug deep within the VideoJS library. VideoJS has recently launched version 2.0.1, but for our development purposes it isn’t stable enough for us to use. The bug may very well’ve been fixed; the engine has really received a large overhaul.
The bug itself is that when subtitles are playing, scrolling forwards through the video will update the subtitles appropriately. Scrolling backwards however, does not. The subtitles do not update at all, but rather freeze in place. The issue was that in the OnTimeUpdate function, a loop for finding the newly scrolled to position was only checking forwards. A quick change and it was working. From here the changes were simple. To enable subtitle toggling on the version of VideoJS in the BBB project:
- Setup a video.js page as before
- Make a checkbox, give it an id (lets say you give it the id chkCC)
- Add this attribute to the video element: data-subToggle=”chkCC”
- VideoJS automatically hooks into the click event for the checkbox and will toggle subtitle display
I’ve also submitted a patch to the VideoJS team. Watch for it in new releases of VideoJS or help them build a stable 2.0. You can see the fix in action here.
Bookmark/API changes
To stick to conventions a bit better, we’ve renamed our global object from “Mgr” to “bbb”. This way it’s indicative of the project and is lowercase so as not to be confused with Constructor conventions.
The Bookmark object has also been refactored for convention and memory usage reasons. The equals and getJSON functions have been moved to the prototype, and instantiated Bookmark objects now requires using the “new” keyword. Before, it was simply bbb.Bookmark(params). These were completed as part of Kevin’s and my effort at merging our 0.2 releases together. You can download the unified 0.2 here.
Looking Forward
The easy stuff is off the list, which now stands at:
Hooking up dummy server calls on chapter addition/deletionToggle subtitles on/offRefactor Bookmark object to optimize for memory consumption- Time In/Out Buttons for setting chapters rather than manual typing
- Popcorn-formatted metadata generation (will be sent to same dummy server)


