Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

JS Error: SWFObject is not defined


I get the above error ...I get the above error message in Firefox error console using JW Media Player 3.13. The code line in question looks like this:

var so = new SWFObject('/global/embed/mediaplayer.swf','mpl','416','272','7');

Any ideas?

25 Community Answers

JW Player

User  
1 rated :

make sure you have this line first bc.. <script type="text/javascript" src="swfobject.js"></script>
and that you have uploaded the *swfobject.js* to the server where the page expects it...

JW Player

User  
1 rated :

I copied the original script from the JW website. It started:
bc.. <script type="text/javascript" src="swfobject.js" />
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('/global/embed/mediaplayer.swf','mpl','416','272','7');
etc.

Then I changed it to:
bc.. <script type="text/javascript" src="swfobject.js">
var so = new SWFObject('/global/embed/mediaplayer.swf','mpl','416','272','7');
etc.

Now it works like a charm. No more js errors. Thanks for your advice!
Maybe the original script should be changed to avoid that more people download a script causing errors?

JW Player

User  
1 rated :

you also need the </script> as in the first posting, to be completely correct...
the /> ending is actually valid xhtml so you are probably using a strict html4 dtd -
but JeroenW is in the process of updating everything, so it will be changed in the wizard soon also...

JW Player

User  
1 rated :

Actually, I am using xhtml1.0 strict but serving application/xhtml+xml mimetype to browsers that can cope with it, text/html to IE. Maybe this has something to do with the error. Anyway, now it works so I'm happy :-)

JW Player

User  
1 rated :

ah, application/xhtml+xml seem to be the culprit then - there was some other users recently having problems with that too -
http://www.jeroenwijering.com/?thread=6635 and http://www.jeroenwijering.com/?thread=6675#msg34367
so, thanks for the info, good to know and keep an eye out for!

JW Player

User  
1 rated :

Hi guys,

I have a similar problem:

http://www.mirosonic.com/index-1.html

Here is the code:

<div style="border: 1px solid rgb(96, 96, 96); padding: 0px; width: 400px; height: 134px; background-color: rgb(34, 34, 34);">
<script type="text/javascript" src="http://www.mirosonic.com/swfobject.js"></script>
<script type="text/javascript" src="http://www.mirosonic.com/swfobject.js"></script>
<div id="player">This text
will be replaced</div>

<script type="text/javascript">var so = new SWFObject('http://www.mirosonic.com/mediaplayer.swf','mp1','400','134','8');so.addParam('allowscriptaccess','always');so.addParam('allowfullscreen','true');so.addVariable('height','134');
so.addVariable('width','400');
so.addVariable('file','http://www.mirosonic.com/media-player-1.xml');
so.addVariable('backcolor','0x000000');
so.addVariable('frontcolor','0x666666');
so.addVariable('lightcolor','0xCCCCCC');
so.addVariable('screencolor','0x000000');
so.addVariable('displaywidth','140');
so.addVariable('showstop','true'); so.addVariable('showdownload','true');
so.addVariable('showdigits','true');
so.addVariable('bufferlength','5');
so.write('player');
</script>
</div>

All of the file paths seem okay, but I get a SWFObject undefined error message

Would appreciate you advice

JW Player

User  
0 rated :

You are loading *swfobject.js* twice here:bc.. <script type="text/javascript" src="http://www.mirosonic.com/swfobject.js"></script>
<script type="text/javascript" src="http://www.mirosonic.com/swfobject.js"></script>
Once is enough. One of those lines of code should be in the head element of your HTML page. The other one should disappear into stray electron land (delete it).

JW Player

User  
0 rated :

i am unable to attach this menu in my site.
swf is loading but no action.

pls help

rajnikant.sharma@3dbp.in


originally running on :

www.3dblueprint.nl

i want to attach it in

www.3dblueprint.in


----------------------------menu.html-------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" lang="en">
<head>

<script src="media/menu.js" type="text/javascript"></script>
<link href="media/style.css" type="text/css" rel="stylesheet" />

</head>
<title>3D BluePrint</title>
<body>
<div class="page">
<script src="media/menu.js" type="text/javascript"></script>
<div class="navigation" id="flash_menu">
<ul class="top" id="navtop">
<li>Menu is loading...</li>
</ul>
<ul class="bottom" id="navsub">
<li>To navigate the menu you should have flash player. <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW" target="_blank">Click Here To Download</a></li>
</ul>
</div>
<script type="text/javascript">
// <![CDATA[
var fo = new FlashObject("media/flash/container.swf", "container", "776", "64", "8.0.22", "#aab2c3" );
fo.addVariable("path", "media/flash/menu.swf");
fo.write("flash_menu");
// ]]>
</script>

</div>
</body>
</html>


---------------------------------------------
---------------------------menu.js-----------------------------------------------
var W3CDOM = (document.createElement && document.getElementsByTagName);

var images = new Array();

function ProjectListOver(cachefile, id){

obj = document.getElementById(id);
obj.style.backgroundImage='url(./cache/thumbs/thumb_normal_' + cachefile + ')';

obj.onmouseout = function () {
obj.style.backgroundImage='url(./cache/thumbs/thumb_' + cachefile + ')';
}

}

function ProjectListOver(cachefile, id){
obj = document.getElementById(id);
obj.src='./cache/thumbs/thumb_normal_' + cachefile;
}

function ProjectListOut(cachefile, id){
obj = document.getElementById(id);
obj.src='./cache/thumbs/thumb_' + cachefile;
}

function printpage() {
window.print();
}

function mailpage(){
mail_str = "mailto:?subject=" + document.title;
mail_str += "&body=" + location.href;
location.href = mail_str;
}

function showLayer(id){

obj = document.getElementById(id);
obj.style.display = (obj.style.display=="block") ? "none" : "block";

}


/**
* FlashObject v1.2.3: Flash detection and embed - http://blog.deconcept.com/flashobject/
*
* FlashObject is (c) 2005 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
if(typeof com == "undefined") var com = new Object();
if(typeof com.deconcept == "undefined") com.deconcept = new Object();
if(typeof com.deconcept.util == "undefined") com.deconcept.util = new Object();
if(typeof com.deconcept.FlashObjectUtil == "undefined") com.deconcept.FlashObjectUtil = new Object();
com.deconcept.FlashObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, redirectUrl, detectKey){
this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
this.skipDetect = com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params = new Object();
this.variables = new Object();
this.attributes = new Array();

if(swf) this.setAttribute('swf', swf);
if(id) this.setAttribute('id', id);
if(w) this.setAttribute('width', w);
if(h) this.setAttribute('height', h);
if(ver) this.setAttribute('version', new com.deconcept.PlayerVersion(ver.toString().split(".")));
if(c) this.addParam('bgcolor', c);
var q = quality ? quality : 'high';
this.addParam('quality', q);
this.setAttribute('redirectUrl', '');
if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
if(useExpressInstall) {
// check to see if we need to do an express install
var expressInstallReqVer = new com.deconcept.PlayerVersion([6,0,65]);
var installedVer = com.deconcept.FlashObjectUtil.getPlayerVersion();
if (installedVer.versionIsValid(expressInstallReqVer) && !installedVer.versionIsValid(this.getAttribute('version'))) {
this.setAttribute('doExpressInstall', true);
}
} else {
this.setAttribute('doExpressInstall', false);
}
}
com.deconcept.FlashObject.prototype.setAttribute = function(name, value){
this.attributes[name] = value;
}
com.deconcept.FlashObject.prototype.getAttribute = function(name){
return this.attributes[name];
}
com.deconcept.FlashObject.prototype.getAttributes = function(){
return this.attributes;
}
com.deconcept.FlashObject.prototype.addParam = function(name, value){
this.params[name] = value;
}
com.deconcept.FlashObject.prototype.getParams = function(){
return this.params;
}
com.deconcept.FlashObject.prototype.getParam = function(name){
return this.params[name];
}
com.deconcept.FlashObject.prototype.addVariable = function(name, value){
this.variables[name] = value;
}
com.deconcept.FlashObject.prototype.getVariable = function(name){
return this.variables[name];
}
com.deconcept.FlashObject.prototype.getVariables = function(){
return this.variables;
}
com.deconcept.FlashObject.prototype.getParamTags = function(){
var paramTags = ""; var key; var params = this.getParams();
for(key in params) {
paramTags += '<param name="' + key + '" value="' + params[key] + '" />';
}
return paramTags;
}
com.deconcept.FlashObject.prototype.getVariablePairs = function(){
var variablePairs = new Array();
var key;
var variables = this.getVariables();
for(key in variables){
variablePairs.push(key +"="+ variables[key]);
}
return variablePairs;
}
com.deconcept.FlashObject.prototype.getHTML = function() {
var flashHTML = "";
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
flashHTML += '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" id="'+ this.getAttribute('id') + '" name="'+ this.getAttribute('id') +'"';
var params = this.getParams();
for(var key in params){ flashHTML += ' '+ key +'="'+ params[key] +'"'; }
pairs = this.getVariablePairs().join("&");
if (pairs.length > 0){ flashHTML += ' flashvars="'+ pairs +'"'; }
flashHTML += '></embed>';
} else { // PC IE
if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" id="'+ this.getAttribute('id') +'">';
flashHTML += '<param name="movie" value="' + this.getAttribute('swf') + '" />';
var tags = this.getParamTags();
if(tags.length > 0){ flashHTML += tags; }
var pairs = this.getVariablePairs().join("&");
if(pairs.length > 0){ flashHTML += '<param name="flashvars" value="'+ pairs +'" />'; }
flashHTML += '</object>';
}
return flashHTML;
}
com.deconcept.FlashObject.prototype.write = function(elementId){
if(this.skipDetect || this.getAttribute('doExpressInstall') || com.deconcept.FlashObjectUtil.getPlayerVersion().versionIsValid(this.getAttribute('version'))){
if(document.getElementById){
if (this.getAttribute('doExpressInstall')) {
this.addVariable("MMredirectURL", escape(window.location));
//document.title = document.title.slice(0, 47) + " - Flash Player Installation";
this.addVariable("MMdoctitle", document.title);
}
document.getElementById(elementId).innerHTML = this.getHTML();
}
}else{
if(this.getAttribute('redirectUrl') != "") {
document.location.replace(this.getAttribute('redirectUrl'));
}
}
}
/* ---- detection functions ---- */
com.deconcept.FlashObjectUtil.getPlayerVersion = function(){
var PlayerVersion = new com.deconcept.PlayerVersion(0,0,0);
if(navigator.plugins && navigator.mimeTypes.length){
var x = navigator.plugins["Shockwave Flash"];
if(x && x.description) {
PlayerVersion = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
}
}else if (window.ActiveXObject){
try {
var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
PlayerVersion = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
} catch (e) {}
}
return PlayerVersion;
}
com.deconcept.PlayerVersion = function(arrVersion){
this.major = parseInt(arrVersion[0]) || 0;
this.minor = parseInt(arrVersion[1]) || 0;
this.rev = parseInt(arrVersion[2]) || 0;
}
com.deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
if(this.major < fv.major) return false;
if(this.major > fv.major) return true;
if(this.minor < fv.minor) return false;
if(this.minor > fv.minor) return true;
if(this.rev < fv.rev) return false;
return true;
}
/* ---- get value of query string param ---- */
com.deconcept.util.getRequestParameter = function(param){
var q = document.location.search || document.location.href.hash;
if(q){
var startIndex = q.indexOf(param +"=");
var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
if (q.length > 1 && startIndex > -1) {
return q.substring(q.indexOf("=", startIndex)+1, endIndex);
}
}
return "";
}

/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use / backwards compatibility */
var getQueryParamValue = com.deconcept.util.getRequestParameter;
var FlashObject = com.deconcept.FlashObject;

/*NIET HIER ED

JW Player

User  
0 rated :

Why wouldn't the code below work? I have swfobject.js, player.swf and video.flv in the same folder. It doesn't matter whether I use the full URL or the file system absolute path to these files, i get the same error "swfobject is not defined". Firebug highlights the following line in the code:

swfobject.embedSWF("player.swf", "placeholder1", "320", "196", "9.0.115", false, flashvars, params, attributes);

I have tried the code on three different servers with the same (lack of) results.

Scriptless embedding works, but that is not the way I want to go.

By the way, I took the code directly from this tutorial: http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/JW_API_TEC.html

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>JW API Example 1-2-0-0 - XHTML Validating JW FLV Media Player</title>
<style type="text/css">
#wrapper { position:absolute; left:64px; top:128px; width:320px; height:196px; background-color:#CCCC00; }
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
function createPlayer() {
var flashvars = {
file:"video.flv",
autostart:"true"
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:"player1",
name:"player1"
}
swfobject.embedSWF("player.swf", "placeholder1", "320", "196", "9.0.115", false, flashvars, params, attributes);
}
/* ]]> */
</script>
</head>
<body onload="createPlayer();">
<div id="wrapper">
<div id="placeholder1"></div>
</div>
</body>
</html>

JW Player

User  
0 rated :

Do you have the correct version of swfobject. You don't mention the version that you have, so I'm guessing that you may not be aware that those demos require swfobject v2.1 from here: http://code.google.com/p/swfobject/

JW Player

User  
0 rated :

Thanks kLink. That was the problem. Now it works.

JW Player

User  
0 rated :

Hi All,
i am trying to implement wmv player
Here i write code as follow

<script type="text/javascript" src="wmvplayer.js"></script>
<script type="text/javascript" src="silverlight.js"></script>
<div id="myplayer">the player will be placed here</div>
<script type="text/javascript">
var elm = document.getElementById("myplayer");
var src = 'wmvplayer.xaml';
var cfg = {
file:'video.wmv',
width:'320',
height:'180'
};
var ply = new jeroenwijering.Player(elm,src,cfg);
</script>

i found this error :jeroenwijering is not defined
and player is not display on web page
Please Help Me
Thanks in advance

JW Player

User  
0 rated :

I had the same problem that *Fideri* ... and I think I am not the first one to have this problem.

Reading that post was very helpful.

*"Can everyone in the world please rename swfobject.js to swfobject2_1.js "*

I think is ridiculous to release a file with the same name when is not compatible with the previous one.

JW Player

User  
0 rated :

Hello,
I am getting the swfobject is not defined error, I have downloaded and installed swfobject2_1.js.

Here is a link to my test page http://65.100.78.113/Music flash.html

Thank you

JW Player

User  
0 rated :

Hello,

advancing slowly swfobject is not defined error is gone but now i get a 2032 but only on some files. here is the code im using
bc.. <style type="text/css">
#wrapper1 { width:320px; height:296px; }
</style>

<script type="text/javascript" src="swfobject2_1.js"></script>
<script type="text/javascript">

function deletePlayer(theWrapper, thePlaceholder, thePlayerId) {
swfobject.removeSWF(thePlayerId);
var tmp=document.getElementById(theWrapper);
if (tmp) { tmp.innerHTML = "<div id=" + thePlaceholder + "></div>"; }
}


function createPlayer(theWrapper, thePlaceholder, thePlayerId, theFile, theStart) {
deletePlayer(theWrapper, thePlaceholder, thePlayerId);

var flashvars = {
file:theFile,
autostart:theStart,
playlist:"right",
playlistsize:"250"

}

var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}

var attributes = {
id:thePlayerId,
name:thePlayerId
}

swfobject.embedSWF("player.swf", thePlaceholder, "700", "200", "9.0.115", false, flashvars, params, attributes);
}
</script>
</head>
<body bgcolor="#CCCCCC" onload="createPlayer('wrapper1', 'placeholder1', 'player1', 'playlist_chapters.xml', 'false')" background="../bg.gif">

<a href="http://www.jeroenwijering.com/?item=JW_FLV_Media_Player">
<font size="4" color="#FFFF00">JW FLV Media Player</font></a><br>
<br>
<div id="wrapper1">
<div id="placeholder1"<div>
</div>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="478">
<tr>
<td width="20%" align="center" height="19">

<a href="javascript:createPlayer('wrapper1', 'placeholder1', 'player1', 'myfile.xml', 'true')">
<font color="#00FF00">myfile</font></a></td>
<td width="20%" align="center" height="19">

<a href="javascript:createPlayer('wrapper1', 'placeholder1', 'player1', 'myfile.xml', 'true')">
<font color="#00FF00">myfile</font></a></td>
<td width="20%" align="center" height="19">

<a href="javascript:createPlayer('wrapper1', 'placeholder1', 'player1', 'myfile.xml', 'true')">
<font color="#00FF00">myfile</font></a></td>
<td width="20%" align="center" height="19">

<a href="javascript:createPlayer('wrapper1', 'placeholder1', 'player1', 'myfile.xml', 'true')">
<font color="#00FF00">myfile</font></a></td>
<td width="20%" align="center" height="19">

<a href="javascript:createPlayer('wrapper1', 'placeholder1', 'player1', '.myfilexml', 'true')">
<font color="#00FF00">myfile</font></a></td>
</tr>



thank you

JW Player

User  
0 rated :

2032 is a "Stream Error"; usually means the player can't retrieve the media file. Check the URI in your browser to see if it is Internet accessible. *http://www.mydomain.com/path/mediafile.ext* (Adjust the domain, path, and filename to yours.)

JW Player

User  
0 rated :

OMG!!! I forgot to set the security settings. *Thank you kLink *everything seems to working now.

JW Player

User  
0 rated :

Hi everybody,
we are stuck with the same error, the "swfobject is not defined", even after upgrading swfobject.js to v2.1

after precicely checking the dtd definitions etc., we copied the example from
http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/JW_API_xmpl_0-0-0.html
and *had the same problem!*

not enough, using "save page..." instead of copy&pasting got us a working example! the player.swf is then found in a folder, maybe there's a prob with local links?

PLease, try again to help some nOObs :)

JW Player

User  
0 rated :

Folks, I'm using this code:
<script type="text/javascript" src="/player/swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("player","9.0.98","expressInstall.swf");
</script>

<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="320" height="230">
<param name="movie" value="/player/player.swf" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="file=/player/live.flv&image=/player/live.flv.jpg" />

<object type="application/x-shockwave-flash" data="/player/player.swf" width="320" height="230">
<param name="movie" value="/player/player.swf" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="file=/player/live.flv&image=/player/live.flv.jpg" />
<p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p>
</object>

</object>


It's working both video&preview but I get that JS error: anyone?

JW Player

User  
0 rated :

I'm getting the "swfobject is not defined" error when trying to use the example that comes with the latest download. There is obviously something wrong with the files. Could someone post an update and/or explanation please?

Thanks.


[EDIT] I fixed the issue. The example is still downloading with swfobject 1.5, but it needs to have 2.1 included.

JW Player

User  
0 rated :

i can someone please help me with this it says Webpage error details and the 3rd last line is giving me the error.

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)
Timestamp: Wed, 12 May 2010 10:43:28 UTC


Message: 'swfobject' is undefined
Line: 17
Char: 3
Code: 0
URI: http://www.redd-e.co.za/?




<script type="text/javascript" src="swfobject.js"></script><!-- STEP TWO: configure SWFObject JavaScript and embed CU3ER slider -->


<script type="text/javascript">
var flashvars = {};
flashvars.xml = "config.xml";
flashvars.font = "font.swf";
var attributes = {};
attributes.wmode = "transparent";
attributes.id = "slider";
swfobject.embedSWF("cu3er.swf", "cu3er-container", "800", "360", "9", "expressInstall.swf", flashvars, attributes);
</script>

Ethan Feldman

JW Player Support Agent  
-1 rated :

@red1 – Can you provide a link to where you are running this?

JW Player

User  
1 rated :

i have a same problem when using videobox to display video on my website. can any one help me.
thanks

JW Player

User  
0 rated :

Hi Every one,
I am using swfobject.js library to play video in my website.
It is working fine but seek bar not working.
seek bar not showing how much video have been completed while playing.
And one more thing, total duration of video is not showing. It is showing just 00.00 for every video.

Thank you in advanse
Shanker singh

JW Player

User  
0 rated :

I was also getting this error with JW version 4.2.9, but it turns out that I was using version 2.2 of swfobject.js which doesn't work with this version of JW. I switched back to version 1.5 and videos are all playing again.

This question has received the maximum number of answers.