Sample Review: How2Videos

The new How2Videos sample project for Morfik 2.0 is a very interesting application to go through, if you are want to extend your Morfik development skills. To begin with, this applications mirrors most of the functionality you find in YouTube, which in it self is already interesting.

In order to duplicate YouTube’s core functionality, this application relies on Flash, to provide the video playing capabilities. Flash is also used by that website, which means that the video playback quality is the same, which means that it is pretty much dependent on the quality of the videos you upload into it. Uploading the videos is another interesting point. To accomplish this the How2Videos sample uses the new FlashUploader control which was introduced with the release of AppsBuilder 2.0. Since the site’s entire functionality must, almost by definition, rely on Flash there is no harm in using Flash to handle uploads.

The following screenshot shows the video management portion of the applications administrative area. Assuming there was no real reason to change these bits of the application, while digging around this sample, developers also get an insight at how Morfik staff manage this portion of their website.

Video Management portion of the How2Video sample’s interface.

Another interesting aspect of application development which is covered in this sample is also related to this portion of the management interface: uploading files. Many websites and web-based applications depend on uploading specific content to the server for publishing. This is specially true in the case of adding or changing images published by the application. These sample handles this task in the simplest of ways: linking the FlashUploader control directly to a database table field.

The How2Videos application does not handle the upload of its own videos. This seemed a bit strange at first, but simply going over the data of the few sample videos which are in the project’s database and looking at their URLs, it then became clear. Morfik uses this application in combination with a specialized file hosting service to speed transfer of the content, worldwide.

There is a code module in this application called Common, which is worth looking into. This module implements a class, called TXAppCookies, to support the usage of cookies in your application. This same class is present in likewise named module of the Issue Tracker application, also figured in a previous review. In both cases, though other specific utility functions were added to the module, this class seems to be the same. Perhaps this class could be added directly to the Morfik framework in a future release.

On the subject of coding, while going over some of the modules for this application, I ran into a nifty little trick. Morfik allows the user to create functions which are entirely written in JavaScript, regardless of the language they are coding in. Both in Morfik Pascal and Basic you can create a subroutine who’s body is all JavaScript, but you cannot directly insert inline JavaScript code. By creating a nested JavaScript subroutine, this sample shows how you can execute a single line of JavaScript code right in the middle of your Pascal or Basic code. The following Pascal code snippet shows an example of this.

Procedure frmHomeMainVideo.FullScreenLabelClick(Event: TDOMEvent);

Procedure StopPlayer(Id : String); Javascript;
(*! document.getElementById(Id).sendEvent(‘STOP’); *)

StopPlayer(FlashContainer.Name + ‘_FLV_player’);
OpenForm(‘frmMainVideoPopup’,‘popup’,’“prmVideoID=‘ +
prmVideoID + ‘”,”title=’ + TitleLabel.Caption + ‘”,”modal=true”‘);

As nested subroutines are not a common practice in many programming languages, this little trick might not occur to developers coming into Morfik development from other languages and tools.

Overall this sample helps extend quite a bit the base reference you can draw upon when starting to create a new Morfik project. As with the Issue Tracker sample, the difference in size and complexity of the project pretty much ensures that a lot of new insights can be derived from it, if all you previously had to work with were the smallish samples that are bundled with both Morfik 2.0 versions. It should certainly be worth taking off a couple of hours to run the application and browse through its source code.

This entry was posted in Flash, Programming, Samples, Videos. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>