In a previous post, I showed you how to embed YouTube videos in FBML using
. That solution is easy, but pulling in YouTube videos this way often means your video ends with a series of Google ads – not good, when you’re working on a corporate page or app, and those ads might easily be for a competitor.
There’s no way to embed the normal YouTube player without those Google ads, but there is a reasonably painless solution, using a fabulous Flash video player called JW Player from LongTail Video. They have a free non-commercial version, but I’m guessing if you client cares enough to be torqued about the ads, they can probably spring the $89. Okay okay, $89 seems steep for a video player – but it’s a far cry less than it would cost to hire a Flash programmer to create something from scratch, and from personal experience, JW Player is worth every single penny.
Anyway, it’s actually stupid-simple to embed JW Player in FBML – your code will look something like this:[html][/html]
So all we’re doing is using the standard
code to call up JW Player, and then sticking all of the additional paramters onto the
code that Facebook won’t grok in FBML, but if you click on the little link above the code that lets you generate code for MySpace and blogs, you can see an HTML-only version of all of the options. That HTML still won’t work out of the box in FBML, but it will make it easier to see how to include your additional options.
So, for example, if you wanted to embed a version of JW Player that includes a playlist in the player itself, your FBML would look something like this:[html][/html]
Note that the size is larger, to accomodate the increased height for the playlist. Also note that waitforclick being set to false doesn’t actually work on Static FBML app tabs, as part of Facebook’s policy.
JW Player also supports playing mp3 files without any video at all, so this can be an elegant solution for lots of situations. In fact, although this article was written specifically to help you bypass YouTube ads, the same code applies if you just decide that you like JW Player’s options and would prefer to use it instead of the stock YouTube/Facebook video players.