Oct. 23, 2009gong
Hello,
I use the latest swfobject and the latest jw player.
$(document).ready(function() {
var flashvars = {
file: "http://localhost:55721/Content/Kalimba.mp3",
backcolor: "111111",
frontcolor: "66cc00",
lightcolor: "66cc00",
playlistsize: "200",
skin: "http://localhost:55721/Content/bluemetal.swf",
playlist: "bottom"
};
var params =
{
'allowfullscreen': 'true',
'allowscriptaccess': 'always',
'bgcolor': '#000000'
};
var attributes = {};
swfobject.embedSWF("http://localhost:55721/Content/player-viral.swf", "player", "470", "470", "9.0.0",
"", flashvars, params, attributes);
});
with the above code the player is loaded and my mp3 can be played. In my html head I have:
<script type="text/javascript">
var player = null;
function playerReady(obj) {
player = document.getElementById(obj.id);
alert('ok');
};
</script>
This is never triggered. Why is this? I searched the forum but couldn't find an answer
thanks
Oct. 23, 2009Zachary Ozer
There could be a number of reasons for this. Do you have any other javascript on the page?
Try this:
try {
var myReady = playerReady;
} catch (err){
}
playerReady = function(obj) {
player = document.getElementById(obj.id);
alert('ok');
try {
myReady(obj);
} catch (err){
}
}
Oct. 23, 2009hobbs
You forgot to name the poor thing — now he's running around screaming, "Who am I?"
$(document).ready(function() {
var flashvars = {
file: "http://localhost:55721/Content/Kalimba.mp3",
backcolor: "111111",
frontcolor: "66cc00",
lightcolor: "66cc00",
playlistsize: "200",
skin: "http://localhost:55721/Content/bluemetal.swf",
id:"playerID",
playlist: "bottom"
};
var params =
{
'allowfullscreen': 'true',
'allowscriptaccess': 'always',
'bgcolor': '#000000'
};
var attributes =
{
id:'playerID',
name:'playerID'
};
swfobject.embedSWF("http://localhost:55721/Content/player-viral.swf", "player", "470", "470", "9.0.0",
"", flashvars, params, attributes);
});
Of course, choose any valid attribute string that you want for the player id.
Adobe advises:
From: http://livedocs.adobe.com/flex/201/langref/flash/external/ExternalInterface.html
Note: When embedding SWF files within an HTML page,
make sure that the id and name attributes
of the <object> and <embed> tags
do not include characters such as: . (period), -, +, *, /, and \.
Oct. 23, 2009gong
No other JS are there except jquery. I just making a test page.
With your approach I get a Reference error player ready not defined.
Oct. 23, 2009gong
@hobbs: thanks it works!
Nov. 06, 2009Nathan Colgate
@hobbs: thanks indeed
Nov. 06, 2009hobbs
@gong & Nathan,
You're welcome.
Good Luck!
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.