2 Jun
How to Add YouTube Videos (Flash) to Facebook Static FBML Pages
Posted in Facebook 101 by Greg Biggs No CommentsThe Static FBML Facebook app is a great way to create custom pages with layouts created in CSS/HTML, or by using Facebookâs proprietary FBML (Facebook Markup Language).
Recently, our clients asked us how to embed video in a Static FBML page. Well, you can actually embed any Flash object using FBML, and itâs pretty easy. Hereâs how itâs done if you want to embed a YouTube video (Note: you can use this technique to embed any Flash object with the .swf extension).
PLEASE NOTE:
- Static FBML can only be used on Fan Pages, not Personal Profiles or Group pages.
- You can only use CSS and HTML in these pages, and FBML.
If you canât get this working PLEASE make sure:
- The URLs to both the activation image (imgsrc) and the video or Flash object are correct. You can test them by pasting the URL into your browsers address bar and accessing the image or video channel directly. If you canât access them via this method, your URL is incorrect.
- You have closed the <fb:swf> tag, with </fb:swf>. If the tag isnât closed, it wonât work.
- All quotes are closed. It doesnât matter if theyâre single (â) or double (â), but they must match and they must be closed (width=âxxxâ or width=âxxxâ â NOT width=âxxx or width=âxxx or width=âxxxâ ).
Embed a YouTube video using FBML
Hereâs the code you put on your Static FBML page:
<fb:swf
swfbgcolor="000000" imgstyle="border-width:3px; border-color:white;"
swfsrc='http://www.youtube.com/v/xxxxxxxxxx'
imgsrc='http://img.youtube.com/vi/xxxxxxxxxx/2.jpg' width='340' height='270' />
Replace âxxxxxxxxxxâ with the YouTube video ID, which is the string of characters after the âv=â in the URL in your browserâs address bar (up to the â&â or anything following it, if you see that after the string of letters and numbers). For example:
http://www.youtube.com/watch?v=JOt2Qp0H9G8&feature=related
You would replace âxxxxxxxxxxâ with âJOt2Qp0H9G8âł in both places, resulting in:
<fb:swf
swfbgcolor="000000" imgstyle="border-width:3px; border-color:white;"
swfsrc='http://www.youtube.com/v/JOt2Qp0H9G8'
imgsrc='http://img.youtube.com/vi/JOt2Qp0H9G8/2.jpg' width='340' height='270' />
You can also change the values for âswfbgcolorâ and âimgstyleâ to your preferences.
The value âswfsrcâ is the absolute URL to the Flash file you want to embed (YouTube videos are in Flash format).
The value âimgsrcâ is the preview image. This image is usually 120Ă90 pixels on YouTube, so when you set the width and height variables in the FBML markup, this image will not look so great because youâll definitely want your embedded video to be larger than that. However, you can change the âimgsrcâ URL to point to any image online, so you can create an image at the 340Ă270 dimensions (or whatever dimensions you wish â the 340Ă270 is just an example), upload it to your server (or use an image hosting service like Photobucket to host your images).
On your Fan Page, an image appears first (the value of âimgsrcâ). When the user clicks the image, it turns into the Flash object.
More resources:
Facebook Developer Wiki on Embedding Video




Leave a comment