SharePoint, Technical

Use Flash in SharePoint 2010

The idea of using Flash inside SharePoint 2007 is well documented and I’ve even done it a few times myself.  Smile My preferred method (non-code) is to slap a Content Editor web part (CEWP) on the page, go into the HTML editor, and add my <object> code.  Worked like a charm.

Not so much in 2010.  You can add a CEWP to a 2010 page, you can go into the HTML editor and add your <object> code, but the page will never load the swf file.  There are recommendations out there saying to change the Browser File Handling setting for the web application to Permissive from Strict, but this didn’t fix anything for me (tried in three separate environments.)  What did work is the following method using a Page Viewer web part…

  1. Upload your swf file to a library in your site (I prefer Site Assets library if you’re not using publishing features)
  2. Create a HTML file locally with the content:
       1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

       2: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

       3: <head>

       4: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

       5: <title>Flash Page</title>

       6: </head>

       7: <body>

       8: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="300" height="300" id="&lt;your swf filename here>" align="middle">

       9: <param name="allowScriptAccess" value="sameDomain" />

      10: <param name="movie" value="&lt;your swf filename here>.swf" />

      11: <param name="quality" value="high" />

      12: <param name="bgcolor" value="#ffffff" />

      13: <embed src="http://site/SiteAssets/&amp;amp;lt;your swf filename here>.swf" quality="high" bgcolor="#ffffcc" width="300" height="300" name="<Flash File Name>" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

      14: </object>

      15: </body>

      16: </html>

    Replace the <your swf filename here> with your filename, and changing any other params you need.

  3. Upload the .html file to your Site Assets library (or wherever you put your .swf file)
  4. To test your progress, click on the .html file in the library.  If you’ve done everything right so far, a page should open in your browser which loads the Flash file (it may prompt you to show the file depending on your browser settings)
  5. Copy the URL of the .html file in it’s new location
  6. Navigate to the page where you want the Flash file to appear and go into edit mode
  7. Add a Page Viewer web part
  8. Edit the Page Viewer web part and choose the Web Page option, entering the link to your .html file in the Link text box
  9. Click OK, and ta-da!
  10. You will want to edit the web part again to set height and width, and hide or change the title, etc.  But that’s up to you.

That’s the only method that worked for me.  I found that the Browser File Handling setting had no impact on whether this method worked or not, so don’t worry about messing with that.

Edit: Turns out the Browser File Handling does need to be set to Permissive.  At least it needs to be Permissive when you upload your HTML file.  You can change it back to Strict after that if you need to.  It looks like SharePoint adds the headers during file upload, not run time.  So if you upload the HTML file with Strict, headers get added that prompt the user to download the file instead of just view it in the browser.

21 thoughts on “Use Flash in SharePoint 2010

  1. Hi:

    There is a better way to handle “Browser File Handle” issue. Take a look at my blog here: http://www.pdfsharepoint.com/sharepoint-2010-and-pdf-integration-series-part-1/

    Solution #2 addresses Pdf extension without exposing entire Web Application to “Permissive” browsing. Setting “Browsing File Handle” to “permissive” opens too many vulnerabilities with other file extensions. You just change “application/pdf” to your MIME types.

    Thanks,

    Dmitry

  2. I’m really stuck. I’ve changed to Permissive, tried it as both HTML and ASPX, tried uploading it both before and after the setting change, and added the MIME type of application/x-shockwave-flash through PowerShell. I can’t even get it to load in the created page, nevermind a web part. Oddly enough, I can get it to load a Flash file that exists on a remote SP 2007 server in the web part, but not a local SWF file.

    Since I’m doing this in a test environment, do you think there’s any chance it has to do with a self-signed certificate? Because all files are in a Pages directory on a Publishing Site? Is it being blocked at the list level in the Pages directory rather than the server level even if I set the MIME type as ok?

    I can’t believe how difficult this has become from 2007… was an after thought when I started the upgrade process. Now it’s one of the bigger headaches.

      1. Double update: I went straight to the swf files in the libraries, right-clicked and chose “Open in new tab” and they each opened and ran except for the one causing the issue. Instead it asked me where I wanted to save the file. I canceled the save window and tried to open it in a new tab again. Voila! It opened. I went back to my page with the web part and hit refresh. Double Voila!

        No idea what was going on here, but SP obviously had to refresh something on the list item for it to want to display it in a browser.

        I also found that if you place all of the flash related files at the root of the directory where your page exists, then it has less issues as well (downside is my Pages directory is awfully cluttered). Perhaps I’ll use this opportunity to start changing to Silverlight.

  3. Thanks mate!!…I was banging for a long time….This gave me a sign of relief…Best practice for inserting flash into sharepoint page.

  4. This is great! Thanks for your help. I’ve been looking for a solution like this for a couple of days but couldn’t get it to work! Any advice on how to remove the white space in the upper left hand corner that I assume is added courtesy of IE?

        1. I guess I don’t have an eye for those things…I never noticed that! Does wrapping it in an img tag within the page you’re pulling in with the Page Viewer web part help?

  5. Hi there,

    Thank you for the article and all the information!!

    If I open the html file from my Windows Explorer and it works perfect. The flash file (swf) open in IE. But if I open the html file in the Gallery (this is were my fa-animation.swf file is saved with my html file) or in the Page Viewer I get a message at the bottom of IE that asks me “Do you want to save flashdisplay.html from team.co.za?”. It only asks me to save or cancel, I can’t open and view the file.

    Please help?
    Thank you,
    Regards,
    Marli

    1. Hi Marli, a couple ideas. First, check the content type you’re setting in the HTML page. Do an Internet search if you’re not sure what I’m referring to. Second, you could try changing the extension of that page from .html to .aspx, as that seemed to work for a previous poster. Third, add a simple “hello world” HTML page (without flash) to your library and work on getting that to open in the browser. If you get a simple page to open then the flash page should open as well.

  6. Hi there,

    A Note: after I saved the html file from the website then the message at the bottom of IE asks me if I want to open the file, and the flashfile opens in a new window. It doesn’t open in the Page Viewer on the Home Page as I set it. Please help?

    Thank you

  7. Hello,…thanks for the big assist here regarding this challenging topic. Could you please explain step #2 a bit more as I’m not sure that I’m following how that is done. Am I supposed to copy that code that you showed and paste it into notepad and save it as an html file or insert that code into the page viewer web part?

    I can tell you this:
    As I create my .swf movie in Swish,….there is an option to export the file in both a .swf and html format. Can I use this html file instead of the one above?

    1. You create an HTML file locally using that code, and then upload it to your SharePoint site. I’m not familiar with Swish and what it creates for an HTML file so I can’t say if that could replace what I have here.

  8. One problem I did come across with the Page viewer web part was that it supersedes everything else around it. If you have a flyout menu,…the flyout or drop down will be blocked by the webpart thus obstructing the view. Weird.

  9. Hi Ryan

    I know this article is really old by now but I just wanted to say a big THANK YOU because this worked perfectly for me first time. Which, when it comes to Sharepoint, this is not something I’ve been able to say very often.

    Thanks again and I’ll be sure to come back to your blog for help in the future.

Leave a Reply

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