Snipe.Net Geeky, sweary things.

Using JW Player in FBML to Bypass YouTube Video Ads

U

In a previous post, I showed you how to embed YouTube videos in FBML using or . 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 swfsrc.

We can extend this to include any of the (extensive) options that JW Player supports – and it’s an impressive list. They even provide a handy wizard that lets you pick all of your options and will generate the HTML/JS code for you. Of course, the default code they generate will not work in FBML, since it uses non-FBJS JavaScript and 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.

About the author

snipe

I'm a tech nerd from NY/CA now living in Lisbon, Portugal. I run Grokability, Inc, and run several open source projects, including Snipe-IT Asset Management. Tweet at me @snipeyhead, skeet me at @snipe.lol, or read more...

By snipe
Snipe.Net Geeky, sweary things.

About Me

I'm a tech nerd from NY/CA now living in Lisbon, Portugal. I run Grokability, Inc, and run several open source projects, including Snipe-IT Asset Management. Tweet at me @snipeyhead, skeet me at @snipe.lol, or read more...

Get in Touch