views:

1252

answers:

1

I am trying to do a very minimalistic sample of borderless video using swfobject and some cookie code that checks if a site visitor has been there before. The latter cookie code works, but basic SWFObject 2.2 code doesn't.

My problem is that the SWFObject 2.2 library from code.google is not working as expected; specifically it is NOT obeying the params.play='false' and it is autoplaying the SWF each time, regardless of how i set this attribute (it disobeys). I read a cookie from the given domain, and should it be set with 'autostart_video=false' I then pass the string "false" to that SWFObject play parameter, with the purpose of making it NOT autostart the video upon refresh. The cookie checking code, but the @#$%#$@$ swf code doesn't. In the simplest example below, I've excluded the cookie code altogether to test just the SWFobject code by itself.

The attribute in the code sample below is using static publishing but dynamic publishing method doesn't work either (tried both methods). I was beginning to think there was something wrong with the sample SWF file itself, but tested it with other swfs and they all have this behavior.

The code below was generated using the "SWFObject 2 HTML and JavaScript generator v1.2" that google published.

I tried to reverse the swfobject library, and frankly the code is obfuscated or just well beyond me, so cannot find where it's setting the params and/or autoloading more libraries otherwise i'd not ask for help.

At any rate, please help!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
        <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
            <head>
             <title></title>
             <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
             <script type="text/javascript" src="swfobject/swfobject.js"></script> <!--path is correct-->
             <script type="text/javascript">
              swfobject.registerObject("myFlashContent", "9.0.0");
             </script>
            </head>
            <body>
             <div>
              <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="600" id="myFlashContent" align="middle">
               <param name="movie" value="swfObject2.2-is-retarded.swf" />
               <param name="play" value="false" />
               <param name="loop" value="false" />
               <param name="menu" value="false" />
               <param name="quality" value="autohigh" />
               <param name="scale" value="noscale" />
               <param name="wmode" value="transparent" />
               <!--[if !IE]>-->
               <object type="application/x-shockwave-flash" data="dwfObject2.2-is-retarded.swf" width="400" height="600" align="middle">
                <param name="play" value="false" />
                <param name="loop" value="false" />
                <param name="menu" value="false" />
                <param name="quality" value="autohigh" />
                <param name="scale" value="noscale" />
                <param name="wmode" value="transparent" />
               <!--<![endif]-->
                <a href="http://www.adobe.com/go/getflashplayer"&gt;
                 <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                </a>
               <!--[if !IE]>-->
               </object>
               <!--<![endif]-->
              </object>
             </div>
            </body>
        </html>
A: 

<param name="play" value="false" /> isn't designed to stop a video from playing, only the SWF.

Most video player SWFs are not timeline-based and are ActionScript-based instead. This means they are almost 100% AS, which usually means they only consist of one or two frames. If there is only one frame in the project, and the project relies on ActionScript to do stuff, stopping the SWF on the first frame will have zero effect... the ActionScript on frame one will still execute. In turn, the linked video will still be loaded and will play.

So what you'll need to do is determine if your player SWF has an internal variable you can set to prevent auto-play. This then needs to be communicated to the SWF using the FlashVars param, not the "autoplay" param -- that param simply tells Flash Player not to let the SWF go past frame one when loaded. It doesn't prevent ActionScript from executing, and is completely independent from the video controller.

For example, if your video player SWF uses an internal variable named "autostart", and it accepts a boolean as an argument, you'd write it as:

<param name="flashvars" value="autostart=false" />

Check the documentation for your video player SWF to see what flashvars are available to you.

pipwerks
Thank you thank you! the video was made into a swf by importing a flv and publishing it as a swf by placing the flv into the first keyframe of a single layer, so it is timeline based. Still, your answer is very informative and gives me a means to investigate further.Thanks again!!
Cneg