Parameters in flashVars

The flashVars is a method of passing variables to a SWF file. FlashVars is a name/value collection seperated using ampersands (&):

<embed type="application/x-shockwave-flash"
  pluginspage="http://www.adobe.com/go/getflashplayer"
  allowscriptaccess="always"
  flashvars="&fileName=video.flv&autoStart=true&"
  allowfullscreen="true"
  bgcolor="#000000"
  quality="high"
  name="VideoPlayer"
  src="VideoPlayer.swf">
</embed> 

The example above is a fictive example embedding a videplayer. The videoplayer takes 2 parameters, the video name and a boolean telling the player to autostart.

But what if the video name is not a physical file, but an URL with parameters, for example http://www.mysite.com/videostream.ashx?videoid=1&quality=high. This URL contains an ampersand, which conflicts with the flashVars, as flashVars uses ampersand to seperate its own parameters. This would be invalid:

flashvars=”&fileName=http://www.mysite.com/videostream.ashx?videoid=1&quality=high&autoStart=true&”

You need to replace your &’s in the URL with %26. This is valid:

flashvars=”&fileName=http://www.mysite.com/videostream.ashx?videoid=1%26quality=high&autoStart=true&”

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in c#, General .NET and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s