Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

swfobject.js vs Embed HTML

13 replies [Last post]

Question:
Say I wanted to provide an HTML sample for copy and pasting embed tags, next to the video. If I'm going to be generating the embed tag HTML already, what's the point of having a separate swfobject.js? In my case, would swfobject.js be superfluous?

The savvy web developer uses Swfobject not just because it does the embedding, but because it does the embedding in a way that maximises the number of browsers that display it the same. Embedding is still a rather dark art and swfobject ensures you don't have to be a psychic to predict what browser your visitors are using.

Another important feature is that Swfobject also supports the provision of alternate content for users without JS or Flash installed/enabled, so that a pleasant, helpful message is display to try and improve installation and viewing of your video.

The point of still using swfobject therefore, is because you want users to view the videos on your site, right? Swfobject helps ensure the maximum possible number of users will see the video and if they can't see it, they'll be told how to see it in your 'alternate' content.

Its one thing if users can't watch the video after someone has cut and paste the embed code you provide onto another site, but its a complete fail if users can't even seen the video on the origin site!

Sites that provide users with bog-standard html tag embedding, do so not because that method is sufficient (far from it) but simply because its ridiculous to ask users to do it this advanced way.

i cann't understand about embed html.
how can run it?

where will i get the file swfobject.js

 
"where will i get the file swfobject.js"

    http://www.google.com/search?hl=en&q=swfobject&aq=f&oq=&aqi=g%3Ap2g8

Make sure that you get the correct version (1.5 or 2.2) for the code format that you are using.

I don't understand this -- We've used the standard object-param-embed tags for quite some time, with cross-browser compatibility across A-grade browsers, with no problems. Adding another JS library to do this seems like a performance hit, and it doesn't degrade automatically for non-JS clients, among other things.

95% of web users have Javascript enabled. So that point is moot.

If you are looking for the RIGHT method for embedding Flash players in a modern, efficient site, swfobject is the way to go. There are a few reasons:

1) Many active embeds on a page are slow, and unreliable. Using swfobject, you can instantiate your Flash players as necessary on-click, instead of having them load as the page does.

2) Using a good swfobject implementation, you can instantiate your browsers after the DOM has been formed. This is just good practice.

3) Adding and removing swfobject instances as needed is a sure-fire way to keep your page from bogging down the users' browser when they aren't in use (this is great for modal implementations).

4) swfobject is light-weight; I would say any performance hit (if there were one) would be more than offset by the potential gains.

The advantages of using swfobject v2.x loaded from Google's CDN:

    Loading from Google AJAX Libraries API:

        http://pipwerks.com/journal/2008/11/11/swfobjectjs-finds-a-home-on-google-servers/

    How & Why You Should Use Google CDN:

        http://webmuch.com/how-why-you-should-use-google-cdn/
 
 
And finally, reading the documentation may enlighten you a bit.

      http://code.google.com/p/swfobject/wiki/documentation
 
 
Oh, and did I mention that swfobject has an extensive API?

      http://code.google.com/p/swfobject/wiki/api
 
 
Now days, most users are doing much more than just embedding a Flash banner, so swfobject becomes quite useful to them.

Some specs simply require a javascript-less, standards-compliant solution, unfortunately.

You can just copy & paste the object code that swfobject generates into your HTML — issue solved.

I tried the following code and it did not worked

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>JW Player for Flash</title>

<style type="text/css">
body { background-color: #fff; padding: 0 20px; color:#000; font: 13px/18px Arial, sans-serif; }
a { color: #360; }
h3 { padding-top: 20px; }
ol { margin:5px 0 15px 16px; padding:0; list-style-type:square; }
</style>
<script type='text/javascript' src='swfobject.js'></script>

</head>
<body><div id='mediaspace'>This text will be replaced</div>

<script type='text/javascript'>
  var so = new SWFObject('player.swf','mpl','470','290','9');
  so.addParam('allowfullscreen','true');
  so.addParam('allowscriptaccess','always');
  so.addParam('wmode','opaque');
  so.addVariable('file','avatar.flv');
  so.addVariable('streamer','rtmp://localhost/oflaDemo');
  so.write('mediaspace');
</script>

</body>
</html>

@Tapas Mishra - Can you provide a link to where you are running this?

Hi, I got every thing working and resolved.

The code on the first post of mine I have not kept it in Document Root of the webserver.
That was the only thing that was stopping things.
I had made all the html code in my home directory.

Good, glad you got it working! :-)