I have a javascript question. I'm trying to dynamically build a plugins string variable (optPlugins) and insert into a setup for jwplayer but it doesn't work. For example:
This does not work:
function jsCreatePlayer(sStartVid)
{
var optPlugins = '{ "dplaylists-1": { "dxmlpaths": "/jw/playlist_latest.xml", "dposition": "top", "dskin": "/jw/DPlaylistsSample.swf", "dtarget": "_self" } }';
jwplayer('mainplayer').setup({
'flashplayer': '/jw/player.swf',
'file': sStartVid,
'plugins': optPlugins,
'autostart': 'true',
'width': '577',
'height': '324'
});
}
This does:
function jsCreatePlayer(sStartVid)
{
jwplayer('mainplayer').setup({
'flashplayer': '/jw/player.swf',
'file': sStartVid,
'plugins': { "dplaylists-1": { "dxmlpaths": "/jw/playlist_latest.xml", "dposition": "top", "dskin": "/jw/DPlaylistsSample.swf", "dtarget": "_self" } },
'autostart': 'true',
'width': '577',
'height': '324'
});
}
Note the only different between the two is I copy the optPlugins var right into the plugins:. I'm not good with this, are these JSON options or something? How would I get jwplayer's .setup to properly eval(?) optPlugins? Its not a jwplayer problem, I could just as easily have this question for jquery options too I think.
Thanks.
use like following code,
var optPlugins = { "dplaylists-1": { "dxmlpaths": "/jw/playlist_latest.xml", "dposition": "top", "dskin": "/jw/DPlaylistsSample.swf", "dtarget": "_self" } };