Thursday 30 July 2009

Liferay Flash Movie Hack

Currently were displaying a company movie in some journal article on our Liferay portal, but the movie isn't located on the Liferay server itself. This was all working nice and dandy, but now the server it is hosted on is being migrated and the hack we used to host the movie on it won't be available on the new server. The hack we used was to place the movie file into a custom folder inside the 'docroot' folder of a Glassfish domain.

Since the server was being migrated and it was already a hack, something had to change, preferably for the better. So we were looking into placing the movie, the movie player and the skin for the movie player, all .flv files into the Liferay document library. Well this is were we ran into the first problems:
  • File extension: .flv and .swf files can't be added to the library by default. Solution: adding dl.file.extensions=.flv,.swf,.mov,.avi,.mp4,.mp3,.m4v,.bmp,.css,.doc,.dot,.gif,.gz,.htm,.html,.jpg,.js,.lar,.odb,.odf,.odg,.odp,.ods,.odt,.pdf,.png,.ppt,.rtf,.swf,.sxc,.sxi,.sxw,.tar,.tiff,.tgz,.txt,.vsd,.xls,.xml,.zip to your portal-ext.properties and restarting the portal. We also tried dl.file.extensions=* and dl.file.extensions=.*, but both didn't work as expected.
  • File size: the movie file turned out to be to big for the document library, but this can be solved by adding dl.file.max.size=0 to your portal-ext.properties and restarting the portal.
So now we had all the necessary files present in the Liferay document library, so you would think that we would only have to switch out the URLs in our movie journal article and hey presto! But, this didn't work. The page would show up, but the movie wouldn't. So after Googling a bit and looking around the Liferay forums, we found a promising post that claims that you have to URLEncode the document URLs and then it should work. We tried this in various ways, by hand and by using a Velocity template to do the hard work in a repeatable way, but still the movie wouldn't show.

Now we were getting desperate, what other possibilities were left? A custom portlet maybe? We tried some more of the stuff mentioned in the Liferay forums, when we saw some reference to Flash content in the following path /html/js/flashutils/player.swf. We check our Liferay installation and in the /webapps/ROOT directory we found a /html directory. We created a new directory, media, beneath it, placed our three Flash files in it and referenced to them from our journal article as follows (other paths are similar):

<param name="movie" value="/html/media/movie.flv" />

We saved the article, browsed to the correct page and now the movie is shown in its full glory. Disclaimer: this is a dirty hack, we don't recommend to use it, certainly not in a structural way, but until we've found a better, working solution, this does solve our problem for now.

2 comments:

  1. Great work; Boss Canu plz tell me how u are referring file from document library to Journal portlet(web content)

    ReplyDelete
  2. @sree We aren't referring to a file in the document library, that's the point. We tried it and couldn't get it to work. Placing the file inside of the 'html' directory in the Liferay application did work, but in that way you can't add files via the document library or view them in it. We needed to manually transfer the file to the server and copy it the that directory in Liferay.

    ReplyDelete