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:

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:

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.

Advertisement

468x60_makemoney

Advertisement

Themeforest
fbml-share
Previous post

CSS for Custom Share Button in FBML

fb-api
Next post

Hate Facebook Games? Turn Off the API

snipe

snipe

I’m a tech geek/dev/infosec-nerd/scuba diver/blacksmith/sword-fighter/crime fighter/ENTP/warcrafter/activist. I'm the CTO at Mass Mosaic and the CEO of Grokability, Inc. in San Diego, CA. Tweet at me @snipeyhead or read more...

  • Iva

    Thank you!!! 🙂 It’s closely related to what I asked, which means I get it.

  • Glad it helped! I have to do this a lot, although usually with custom flash players, since our clients wouldn’t want competitor ads showing on their video (totally understood), so seemed good to jot down while it’s fresh in my head.

  • Haglund_victor

    Hi Snip!
    Just wanted to give you kudos and love all the way from Sweden. Great page, and I am using most of the FB codes presented here on my fanpages. Keep up the good work, very much aprichiated!

    Best regards Victor

  • Christopher Scott Knell

    After a few hours of Googlin’, I found this page of yours and it did the trick.
    Thanks so much.
    Here it is in action:

    http://www.facebook.com/pages/Digital-Cinema-Society/157078964329711?v=app_4949752878

    FYI: Your FB Connect is ka-put. Not able to log in with it.

    • Great, glad it helped! As for FB Connect, that’s all managed with Disqus. Must be a problem on Disqus’ or FB’s end.

  • john

    hi, i’m tryin to make to autoloop a flv on my fanpage but i can’t figure out the codes. I want to make it looks like something similar to this http://www.facebook.com/pages/Stacey-Oster-Thompson/139577280398?v=app_7146470109. Could you please help me out?

  • dave

    Is JW Player against youtube terms of service? I can’t find a definitive answer anywhere. My player has the youtube logo which links back to youtube, so I think that’s cool, but it also blocks the regular youtube ads and has my own (and longtails) preroll ads showing, is that ok?

    Cheers

    • I don’t really know. I’ve never seen anything that specifically prohibited it.

  • Jurotek

    U can eliminate adds by adding &rel=0 after URL

    • That doesn’t eliminate ads, that gets rid of the “related videos” screen that shows at the end of the video.