Oct. 21, 2009erosophe
Hello,
I'm trying to interact with the javascript API for a jw_player that's instantiated via the a wordpress plugin ( http://sexywp.com/flash-player-widget.htm for the plugin page).
The player seems to work fine, but playerReady() is apparently never called no matter what. From reading these forums I see that that's not entirely unfamiliar, so I am just getting the id of the player via document.getElementbyId. I think it works, because if I use firebug to view the final generated source for the page, I see that the jw_player object does indeed have the id that I think it does.
But if I then do:
---
var id = [id of player];
var player = document.getElementById(id);
alert(player.getConfig().autostart);
---
I get "player.getConfig() is not a function" - even though I know that the player has initialized correctly, because I'm looking at it and it can play files, etc.
I'm reasonably certain that I'm referring to the correct object - but I have no idea why none of the API functions seem to be available.
Any assistance would be most appreciated. Thanks!
Oct. 21, 2009hobbs
Try this.
var player = document.getElementById('playerID'); // adjust to your player id
alert('Player ID: ' + player.id); // should alert "Player ID: playerID"
var config = player.getConfig();
var configo = 'Config:';
for(var j in config)
{
configo += '\n' + j + ': ' + config[j];
}
confirm(configo); // should dump the entire config object
To make the JS API fully cross-browser/cross-OS you need to use your player ID in three places.
1) the id attribute of the object element,
2) the name atribute of the object element,
3) the flashvar id.
Oct. 22, 2009erosophe
Thanks - but this throws an error because, again, 'player.getConfig() is not a function'.
The problem seems to be that
--
var player = document.getElementById('playerID');
--
sets 'player' to something other than the actual player object itself...
Any other thoughts?
Oct. 22, 2009hobbs
What is the actual player id string that you have in the three places that I listed in my post?
Oct. 22, 2009erosophe
Here's the string embedding the object - I have yet to figure out how to edit this, since it's automatically generated by the wp plugin code.
It looks to me like only the id of the object is set, and the name of the object, plus the flashvars id, aren't - do you think that's the problem? If so, it's a matter of figuring out how the plugin generates this code, and fixing it...
<OBJECT type="application/x-shockwave-flash" data="http://example.net/wp-content/plugins/fmp-jw-files/player/player.swf" width="164" height="150" id="cssae85a9e15d9a3bcd0b831c410e171635" style="visibility: visible; "><PARAM name="wmode" value="opaque"><PARAM name="quality" value="high"><PARAM name="allowFullScreen" value="true"><PARAM name="allowScriptAccess" value="true"><PARAM name="flashvars" value="config=http%3A%2F%2Fexample.net%2Fwp-content%2Ffmp-jw-files%2Fconfigs%2Ffmp_jw_widget_config.xml?1208436403&file=http%3A%2F%2Fexample.net%2Fwp-content%2Ffmp-jw-files%2Fplaylists%2Ffmp_jw_widget_playlist.xml?1309971670&skin=http%3A%2F%2Fexample.net%2Fmedia%2Fskin%2Fmodieus.swf"></OBJECT>
Oct. 22, 2009lost
For all Operating Systems except *nix, you must have the name and id set.
For *nix Operating Systems, you must also have the id flashvar set.
You will have to "fix up" the Wordpress plugin code.
Since you are adding something similar to the id attribute, it should be easy to copy the code that creates the id attribute and use that for the name attribute.
Same with the id flashvar. Find where the flashvars are generated and add the id flashvar.
Oct. 22, 2009erosophe
Turns out the problem was even dumber than this -- I was using v2.3 of the JW Player (because that's what's packaged with the wp plugin and the skin works properly), and it doesn't support the API at all.
Thanks for your help; problem's now solved.
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.