January 31st, 2008 . by polyGeek
Sometimes you don’t know which video you want to play inside of videoMaru. Take the video player below for example. I don’t want to create a different video player for each tutorial I do, because I plan on doing lots of them.
The solution is to use FlashVars to pass a variable into videoMaru and tell it which video to play. Now I have one video player and each instance plays a specific video that I can change via the HTML containing page.
To make things easy you don’t have to write any code to make videoMaru play the video you indicate with FlashVars. It does that automatically.
I’ll also cover how you can pass variables into videoMaru via FlashVars to dynamically change things like the volume on startup through the API.
Here is some information about using the <object>/<embed> tags or SWFobject for FlashVars.
If you have a Wordpress blog and use the Kimili plugin to embed your SWFs then you can use code like this to pass FlashVars.
[kml_flashembed
movie="/pgtv/_videoPlayerTemplate.swf"
height="480" width="640"
fvars="flvAddress=/pgtv/videos/68_flashVars.flv" /]
The code above is what was used to play the video tutorial on this page.
Posted by: polyGeek in API, Video Tutorials, flashVars |
3 Comments »
June 24th, 2007 . by polyGeek
FlashVars is a way of passing data from the HTML host page into Flash via the <object><embed> tags. You can read more about FlashVars at the Adobe site.
You can use Flash vars in two ways with video.Maru.
- flvAddress=someString
- xmlIndex=someNumber
In the first case if you pass flvAddress=someValue to your SWF then that will replace whatever, if anything, is the target path in the videoWindow. This way you can create one video interface that can then load any video you wish without republishing your FLA.
If you haven’t used FlashVars before it’s common to use them in conjunction with server side scripting languages so that ultimately the data that you pass into Flash originated from a database.
The second case you can can use FlashVars to tell it which node in the XML to start playing on startup.
You can also use the two cases together so that you pass both the path to the XML file to load and which node to first start playing.
If you are using the HTML/JavaScript code generated by the Flash authoring tool to publish your SWFs then you would add a line such as the one below to tell your video.Maru video player to load the following FLV: http://polygeek.com/polyGeekTV/videos/water.flv
‘flashvars’, ‘flvAddress=http://polygeek.com/polyGeekTV/videos/water.flv’,
The full code would look something like the sample below.
If you would like to load an XML file and also point to a specific node of the XML at startup then your code would look something like this:
If you use SWFobject then your code would look something like this:
And as a last example. If you have a Wordpress blog and you use the Kimili plugin - like I do - to load SWFs then your code would look like this:
Posted by: polyGeek in flashVars |
5 Comments »