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

Forums

/

swf object 2.x and plugins

20 replies [Last post]

Hi all,

I have recently switched over to SWF object 2 and noticed that most of documentation is shown in swf object 1.5 syntax.

I have had real trouble trying to get any plugins to work and I think I must have the syntax wrong.

for instance.

flashvars.plugins = "gapro-1";
or
flashvars.plugins = "viral-2";

both of these break the embed . Any thoughts/help?

Lowell

 
Code snippets aren't useful.

Can you post the rest of your code or a link to your Test Page so someone can help you?

Does this help?

<script type="text/javascript">

var flashvars = {};

var flashvars = {};
if (swfobject.getQueryParamValue("vidpath")) { flashvars.file= swfobject.getQueryParamValue("vidpath");}

flashvars.skin = "modieus.swf";
flashvars.autostart = "true";
flashvars.plugins = "gapro-1";
flashvars.gapro.accountid = "UA-166248-2";
flashvars.gapro.trackstarts = "true";
flashvars.gapro.trackpercentage = "true";
flashvars.gapro.tracktime = "true";

var params = {};
params.allowfullscreen = "true";
params.AllowScriptAccess = "always";
params.allownetworking = "all";

var attributes = {};
attributes.id = "flvPlayer";
swfobject.embedSWF("player-licensed-viral.swf", "myAlternativeContent", "400", "250", "9.0.0", false, flashvars, params, attributes);

</script>

I happen to think that it's a lot easier to do the name:value pairs like this:

    <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

    <script type="text/javascript">
      var flashvars =
      {
        'skin':                    'modieus',
        'plugins':                 'gapro-1',
        'gapro.accountid':         'UA-166248-2',
        'gapro.trackstarts':       'true',
        'gapro.trackpercentage':   'true',
        'gapro.tracktime':         'true',
        'id':                      'flvPlayer',
        'autostart':               'true'
      };

      var params =
      {
        'allowscriptaccess':       'always',
        'allowfullscreen':         'true',
        'allownetworking':         'all'
      };

      var attributes =
      {
        'id':                      'flvPlayer',
        'name':                    'flvPlayer'
      };

      if(swfobject.getQueryParamValue('vidpath'))
      {
        flashvars.file = swfobject.getQueryParamValue('vidpath');
      }
      else
      {
        flashvars.file = 'somedefaultfile';
      }

      swfobject.embedSWF('player-licensed-viral.swf', 'myAlternativeContent', '400', '250', '9.0.124', false, flashvars, params, attributes);
    </script>

[i]Check for typOs![/i]

Make sure that you have a default for the file flashvar.

For the benefit of your users, and everyone else, please load swfobject v2.2 from Google's CDN.

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/

You can also do the flashvars with the period separator like this, if you so prefer:flashvars['accessibility.fontsize'] = '13';

Wow! That works like a charm and the code is so much easier to read.

I also really appreciate the heads up about the google hosting of SWF object.

one last question, what is the syntax if I want to add another value onto a pre-existing flashvar ( 'plugins') i.e. 'viral-2'

is it just a new line or is there a way to combine them?

<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<script type="text/javascript">
var flashvars =
{
'skin': 'modieus',
'plugins': 'gapro-1',
'plugins': 'viral-2',
'viral.callout': 'always', // none, mouse, always - when callout appears
'viral.functions': 'all', // embed,link,recommendations, all - options to include

'gapro.accountid': 'UA-166248-2',
'gapro.trackstarts': 'true',
'gapro.trackpercentage': 'true',
'gapro.tracktime': 'true',
'id': 'flvPlayer',
'autostart': 'true'
};

var params =
{
'allowscriptaccess': 'always',
'allowfullscreen': 'true',
'allownetworking': 'all'
};

var attributes =
{
'id': 'flvPlayer',
'name': 'flvPlayer'
};

if(swfobject.getQueryParamValue('vidpath'))
{
flashvars.file = swfobject.getQueryParamValue('vidpath');
}
else
{
flashvars.file = 'somedefaultfile';
}

swfobject.embedSWF('player-licensed-viral.swf', 'myAlternativeContent', '400', '250', '9.0.124', false, flashvars, params, attributes);
</script>
thanks again for your help.

Lowell

Massive flashvars reference here: http://developer.longtailvideo.com/trac/wiki/FlashVars
 
Plugins have to be a comma-separated list, NO spaces, like this:'plugins':                 'gapro-1,viral-2',

You're welcome, good luck!

hi there,
I believe i have the same problem.
swfobject 2.1

This is my old script :

<script language="JavaScript" type="text/javascript">
var player = null;
var playItem = null;
var file = null;

if(!(playItem = swfobject.getQueryParamValue('item')))
//{
// default is third item (array counting starts at 0)
//playItem = 1;
//}

if(!(file = swfobject.getQueryParamValue('playlist')))
{
// default playlist
file = 'videos.xml';
}
//alert('Play Item: ' + playItem + '\nFile: ' + file);

function playerReady(obj)
{
player = document.getElementById(obj.id);
playAway();
};

// start the player on the query parameter item
function playAway()
{
if(player)
{
//alert('playAway:\nPlayer: ' + player.id + '\nplayAway - playItem:' + playItem);
player.sendEvent('STOP');
}
else
{
setTimeout("playAway()", 400);
}
};

***some html code****

<script language="JavaScript" type="text/javascript">
var flashvars =
{
file: 'filme/{item_file}',

displayclick: 'play',
bufferlength: '5',
shuffle: 'false',
//repeat: 'list',
//playlist: 'bottom',
//playlistsize: '100',
skin: 'embed/nacht.swf',
stretching: 'uniform',
autostart: 'false',
volume: '100',
quality: 'true',
icons: 'true',
controlbar: 'over',
plugins: 'quickkeys-1,accessibility&accessibility.fontsize=20',

frontcolor: 'CCCCCC',
lightcolor: 'F14611'
};

var params =
{
allowfullscreen: 'true',
allowscriptaccess: 'always',
bgcolor: '#FFFFFF',
wmode: 'opaque'
};

var attributes =
{
id: 'PlayerId',
name: 'PlayerId'
};

swfobject.embedSWF('embed/playertest.swf', 'player', '650', '550', '9.0.124', false, flashvars, params, attributes);
</script>

<div id="playercontainer" class="playercontainer" align="center">

<a id="player" class="player" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">bla bla bla.</a>
</div>

<div id="Player"></div>

accessibility plugin was working nice with player version 4.3. Is working with 4.5-r392 too but i want to put the new captions plugin and is not working.
What can i do?
Thank you.

 

'plugins': 'quickkeys-1,captions-1',
'captions.fontsize': '20',
'captions.state': 'true',
'captions.back': 'true',
'captions.file': encodeURIComponent('http://www.domain.com/path/captions.xml'),

thnx
but not showing the captions
xml playlist:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/' xmlns:jwplayer='http://developer.longtailvideo.com/trac/wiki/FlashFormats'>
<trackList>
<track>
<title>title</title>
<location>title.flv</location>
<image>title.jpg</image>
<jwplayer:captions>title.srt</jwplayer:captions>
</track>
</trackList>
</playlist>

Try with

<jwplayer:captions.file>title.srt</jwplayer:captions.file>

Hi there,

May I ask: "are you confirming, even though most of the examples in site are written based on swfobject 1.5 and even in some places its mentioned as "RECOMMENDED VERSION", we can go ahead and use version 2.x with ease of mind?"

Thanks in advance,
Sepi

Ps:
Looking in pdf files arrived with license order, still can see the implementation of swf based on constructor (v1.5) and nothing in there mentions if swfobject 2x is completely supporting plugins for later or not. Even I cannot see what is the Youtube AS version.... where can I find such answers?!?!?!

@sepi - You can use either method.

Thanks Ethan

np

How do I use two plugins at once? The following code works - except that facebook it does not work at all. I have tried it on its own line (breaks the embed), tried it second, with commas around the name of each plugin, with and without the 'dock' flashvar etc.

What am I doing wrong?

<script type="text/javascript">
var flashvars = {
'file': 'http://www.collierdaily.com/playlist.xml',
'autostart': 'true',
'dock': 'true',
'plugins': 'fbit-1,flow-1'

};

var params = {
'allowfullscreen': 'true',
'allowscriptaccess': 'always',
'bgcolor': '#000000'
};

var attributes = {
'id': 'player1',
'name': 'player1'
};

swfobject.embedSWF('http://www.collierdaily.com/player.swf', 'flashContent', '250', '250', '9', 'false', flashvars, params, attributes);
</script>

@Collier - That code should work, can you provide a link to where you are running this?

I'm still building so the page is not live at this time. I will try to upload it to my server tonight. If I can do so, I'll repost a link.

Okay, thanks.

Ethan - its still rough, but its live. http://www.collierdaily.com/music.html

Another issue I am having is that the play button on the control bar doesn't seem to work and the arrow button on the image in the window is not visible. The tracks play okay when you click the image though. Any insight would be helpful.

You are only running one plugin here, Flow. Can you please try to implement fbit as well?

@lost

Great response... I had one more question. I am hoping to create a grid like playlist and have that tell the player what to play depending on what they click. I noticed this in your code:

if(swfobject.getQueryParamValue('vidpath'))
      {
        flashvars.file = swfobject.getQueryParamValue('vidpath');
      }
      else
      {
        flashvars.file = 'somedefaultfile';
      }

I was wondering what that was for?

Reason I ask is I am going to use the Share plugin and I was looking for a way to have the video title and name and embed code to push into those parameters automatically when the thumbnail grid type playlist is clicked.