• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Elias Interactive

We Grow Beautiful Websites

  • Blog
  • Show Search
Hide Search

Integrate InLine Flash FLV Videos with JQuery "Lightbox" Plugin – FancyBox

Luke Whitson · Jul 12, 2009 · 24 Comments

I recently spend some time integrating an existing Flash FLV video, from a third party, into an existing application using the JQuery “Mac-Style Lighbox” plugin, FancyBox. Within FancyBox, the existing FLV/JavaScript code provided to us worked properly on all browsers that I tested, with the usual exception, IE6. Upon further investigation, I found that it not only did not work on IE6, but IE7 and IE8 as well. While IE6 is to be expected, 7 and 8 were not.

The easy solution would have been to require the third party to re-export the video into a more usable format for our purposes. But I wanted to see what it would take to get the current code to work within our implementation.

I looked over some old code where I had integrated FLV video and found a simple difference. The provided code used JavaScript to embed the Flash object, similar to the following:

<script type="text/javascript">
swfobject.embedSWF(
'player.swf',
{file:'/video.flv',width:'407',height:'320'}
);

</script>

While this code worked fine when embedding the video directly into a page, it did not work in our FancyBox window when viewing with IE.

I am sure there are other solutions, but the quick solution I found was to simply embed the code in the standard Object/Embed method used to embed other video formats, rather than using JavaScript to embed the video file:

<object ...>
<embed
src="player.swf"width="407"
height="320"
wmode="transparent"
flashvars="file=video.flv&autostart=true"/>
</embed>
</object>

FancyBox is a very nice “lightbox” plugin for those using the JQuery library. If your FLV video is not working in IE with your lightbox implementation, try changing the way it is embedded into the page, it may just be as simple as that.

UPDATE:

Here is a little more elaboration on the code I used to get the flash working.

First, make sure you have the “custom.js” file created that makes the function calls for each lightbox that you want to use. In that file you will want a line that looks something like:


$("a.myvideo").fancybox({ params here ]);

Then in the page you want to call the video from, you will have a link that launches the video. Something like

<a class="myvideo" href="#divcontainingvideo">Link</a>.

Below that you will place the hidden <div> layer containing the actual embed source for the flash video.


<div style="display:none" id="divcontainingvideo">
<embed
src="path/to/sourcefile.swf"
width="400"
height="300"
wmode="transparent"
flashvars="file=path/to/sourcfile.flv&autostart=true"
/>
</div>

Share this:

  • Tweet
  • Pocket
  • More
  • Email

Development fancybox, flash, lightbox, video

Reader Interactions

Comments

  1. Steve Bramley says

    July 20, 2009 at 8:22 pm

    Hi there,

    I’ve been looking for a lightweight solution for lightbox flash movies. I’ve been looking into fancybox but their downloadable example doesn’t seem to do anything for flash movies. Can you elaborate on the code you’ve used to implement the embedding of flash into the fancybox element please?

    Reply
  2. lukewhitson says

    July 21, 2009 at 9:35 am

    Hey Steve,

    I agree, the downloadable examples weren’t very thorough. I updated my post to include a little more about my actual implementation. Hope that helps.

    Cheers,
    Luke

    Reply
  3. michael says

    July 23, 2009 at 4:40 pm

    I had a similar problem with flv videos not playing but changed the way the flash was embedded and it works now.

    Do you know how to put the html to embed the flash video in a separate file? (ie the lines that start <div style=”display:none” …) I am going to be placing this exact same markup in a lot of files and it would be nice to only have to include the anchor link in each page (as well as the includes for the js)

    Thanks

    Reply
  4. lukewhitson says

    July 24, 2009 at 8:58 am

    Michael,
    Never tried that before, but seems like you could copy the entire hidden div layer in to a seperate file. Then just use an php include to pull that file in on multiple pages. Let us know if it works out for you.

    Cheers,
    Luke

    Reply
  5. Study Curtin Business School says

    August 4, 2009 at 1:09 am

    Hi Justin,

    Thanks for following up. I forgot to get notified so I struggled on and implemented my own solution: http://www.business.curtin.edu.au/business/future-students/postgraduate-study/flexible-study

    Reply
  6. Michael says

    August 5, 2009 at 10:18 am

    I was able to use the ajax example on the fancy box site to pull in the content from a single file and just add the anchor link and script includes to each file.

    Later,

    Michael

    Reply
  7. Funzo says

    August 7, 2009 at 2:08 pm

    alot easyer than it looks guys, i used the following that seems to work although i cant cross browser test it at this time, my VM is blowing up:

    //put in head, empty parameters means default is used.
    $(document).ready(function() {

    $(“a.myvideo”).fancybox();
    });

    //link to display
    our video

    //java script with hidden div

    The player will show in this paragraph

    var so = new SWFObject(‘http://visiteurope.lastexitlondon.com/mediaplayer/player.swf’, ‘mpl’, ‘425’, ‘355’, ‘9’);
    so.addParam(‘allowscriptaccess’, ‘always’);
    so.addParam(‘allowfullscreen’, ‘true’);
    so.addParam(‘flashvars’, ‘&file=http://visiteurope.lastexitlondon.com/mediaplayer/video.flv&controlbar=bottom&autostart=true’);
    so.write(‘player’);

    thank you very much for the help, im sure i will be back when IE 6 renders it \m/BRING DOWN IE6 \m/

    Reply
  8. Chris says

    September 4, 2009 at 3:12 pm

    I am wondering what the process is for just embedding a SWF file to play using this same technique. I can get the SWF to launch in fancybox, but it’s not centered, and there is a “default” sized fancybox window that floats in the background, even though I set the size of the div to the size of the SWF footprint. The SWF file gets pinned to the upper left hand corner of the fancybox window, no matter what size the SWF file is.

    Any suggestions would be most helpful!

    Reply
  9. Andrew says

    September 23, 2009 at 12:02 pm

    Hello,
    I am experiencing the same problem as Chris says.. any solution?

    Reply
  10. lukewhitson says

    September 23, 2009 at 7:15 pm

    Chris and Andrew,
    Sounds like a CSS issue with the divs. Do you have a URL that shows the issue? Might be able to take a look.

    Reply
  11. Andreq says

    October 10, 2009 at 7:55 am

    I am sorry I have changed the code so I cannot provide you with an example issue page.

    I am not exactly sure where was the problem but I think it was in the wmode=”opaque” …

    I have also made a call of the function with these parameters to manage the size of the box as there was no other way the fancybox would be the size of the flash (even with the flash set at certain size):
    $(“a.flash”).fancybox({
    ‘frameWidth’: 1020,
    ‘frameHeight’: 400,
    ‘hideOnContentClick’:false});
    });

    Reply
  12. melia says

    December 16, 2009 at 1:14 pm

    Hola,
    I embedded the swf in fancybox as you suggested- everything works ok, but I
    cant get the controls(play,pause etc) to show, could you tell me
    how I could get the controls up?
    Thanks!!!

    —-

    Reply
  13. melia says

    December 16, 2009 at 1:18 pm

    code(if it loads this time…):

    </div

    —-

    Reply
  14. fatihturan says

    December 31, 2009 at 3:03 pm

    What do you think about old “Click to activiate…” problem?

    Reply
  15. Fedex says

    January 26, 2010 at 12:35 pm

    Man you are awesome! I was looking for a solution to this issue, I was using “object” tag but the embed one did the trick.

    Thanks!

    Reply
  16. humptygrumpty says

    January 27, 2010 at 11:07 pm

    There’s a much easier way to do this :

    $(function(){
    $(“a.inline-video”).fancybox({ ‘callbackOnShow’:showMovie});
    function showMovie() {
    var flashvars = {};
    var params = {};
    var attributes = {};
    swfobject.embedSWF(“movie.swf”, “fancy_div”, “500”, “500”, “9.0.0”,”expressInstall.swf”, flashvars, params, attributes);
    };
    });

    Using the callback from fancybox, you target the fancybox div to write in the movie.

    Reply
  17. adil says

    February 27, 2010 at 5:02 am

    Hi Guys,

    Can anyone help me about playing swf files in fancybox.

    I have This code:

    $(document).ready(function() {

    $(“a.inline”).fancybox({
    ‘frameWidth’: 800,
    ‘frameHeight’:600

    });

    });

    fancy box opens but i just see the link of swf file. It doesnt start.

    If you wanna see : http://www.isletmeciyiz.biz/portal/flashgaleri.asp

    Thank you.

    Reply
  18. rachel says

    May 27, 2010 at 8:08 pm

    I actually have been trying to do exactly this, and when i put the EMBED in a div with display:none, IE will not display the video in fancybox when i click the link. it works in Firefox but not IE. have you found a workaround for IE??

    Reply
  19. Jason says

    June 28, 2010 at 6:41 pm

    Does anyone have an example of this working that they can share?

    Thank you in advance.

    Reply
  20. lingerie babydoll says

    September 20, 2010 at 9:51 pm

    Hello

    Embedding of flash really drives me mad. Fancybox documentation doesn’t explain this clearly, and when embedding swf as they do on demo page, rather than playing it displays some rubbish code…

    Reply
  21. Prakash says

    February 18, 2011 at 7:19 am

    where to download the setup?

    Reply
  22. Jussi says

    March 1, 2011 at 6:05 pm

    With display:none on the div tag the video will not show in the fancybox window. When I remove the display:none from the div it works. But then I see the embedded video that is meant to be hidden as well. Am I missing something?

    Reply
    • royby says

      September 7, 2011 at 6:26 am

      I would like to see the answer to this query as I am experiencing exactly the same issue

      Reply
      • Lee says

        March 19, 2012 at 5:04 pm

        exactly the same problem…

        Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

From the blog

Magento SVN Usage – Best Practices

How to Create Reusable Apple Mail Templates [video]

I’d rather buy from Harry Potter

The Ecommerce Solution You’ll Find Refreshing (drumroll)

Liberating Constraints

More Posts

Connect with us

  • Facebook
  • RSS
  • Twitter
Affiliate Disclaimer

© 2025 · Elias Interactive · Built on the Genesis Framework

  • Blog
  • Affiliate Disclaimer
  • Home