Solved

Detect Flash Player Version; Install/Upgrade if necessary

Posted on 2006-11-14
11
661 Views
Last Modified: 2012-08-14
I've seen this asked and answered a number of different ways, but I can't make any of the examples work for myself. I need to:
1) Detect the user's Flash Player version
2) Express Install/Upgrade to new version if necessary
3) Ensure that Dreamweaver's JavaScript Active Content workaround is in place (no click/space bar to use controls)
4) Begin playing the SWF

None of Adobe's Flash Player Detection Kit instructions or example files seem to work at all for me - let alone accomplishing all of the above. I know many of you probably do this every day. Would someone please please help?? I'm "just a designer..." :)

My current code, taken from the published Flash8 HTML file, is included below. Let me know if you need any other information. Thanks!!
-----

<!-- saved from url=(0013)about:internet -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>bcam_video</title>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
// -----------------------------------------------------------------------------
// -->
</script>
<script language="VBScript" type="text/vbscript">
<!-- // Visual basic helper required to detect Flash Player ActiveX control version information
Function VBGetSwfVer(i)
  on error resume next
  Dim swControl, swVersion
  swVersion = 0
 
  set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
  if (IsObject(swControl)) then
    swVersion = swControl.GetVariable("$version")
  end if
  VBGetSwfVer = swVersion
End Function
// -->
</script>
<script language="JavaScript1.1" type="text/javascript">
<!-- // Detect Client Browser type
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
      // NS/Opera version >= 3 check for Flash plugin in plugin array
      if (navigator.plugins != null && navigator.plugins.length > 0) {
            if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                  var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                  var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                  descArray = flashDescription.split(" ");
                  tempArrayMajor = descArray[2].split(".");
                  versionMajor = tempArrayMajor[0];
                  versionMinor = tempArrayMajor[1];
                  if ( descArray[3] != "" ) {
                        tempArrayMinor = descArray[3].split("r");
                  } else {
                        tempArrayMinor = descArray[4].split("r");
                  }
                  versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
            } else {
                  flashVer = -1;
            }
      }
      // MSN/WebTV 2.6 supports Flash 4
      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
      // WebTV 2.5 supports Flash 3
      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
      // older WebTV supports Flash 2
      else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
      // Can't detect in all other cases
      else {
            
            flashVer = -1;
      }
      return flashVer;
}
// If called with no parameters this function returns a floating point value
// which should be the version of the Flash Player or 0.0
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
       reqVer = parseFloat(reqMajorVer + "." + reqRevision);
         // loop backwards through the versions until we find the newest version      
      for (i=25;i>0;i--) {      
            if (isIE && isWin && !isOpera) {
                  versionStr = VBGetSwfVer(i);
            } else {
                  versionStr = JSGetSwfVer(i);            
            }
            if (versionStr == -1 ) {
                  return false;
            } else if (versionStr != 0) {
                  if(isIE && isWin && !isOpera) {
                        tempArray         = versionStr.split(" ");
                        tempString        = tempArray[1];
                        versionArray      = tempString .split(",");                        
                  } else {
                        versionArray      = versionStr.split(".");
                  }
                  versionMajor      = versionArray[0];
                  versionMinor      = versionArray[1];
                  versionRevision   = versionArray[2];
                  
                  versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
                  versionNum        = parseFloat(versionString);
              // is the major.revision >= requested major.revision AND the minor version >= requested minor
                  if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
                        return true;
                  } else {
                        return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );      
                  }
            }
      }      
      return (reqVer ? false : 0.0);
}
// -->
</script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<script language="JavaScript" type="text/javascript">
<!--
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if(hasRightVersion) {  // if we've detected an acceptable version
    var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
    + 'width="250" height="230"'
    + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
    + '<param name="movie" value="bcam_video.swf" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />'
    + '<embed src="bcam_video.swf" loop="false" quality="high" bgcolor="#ffffff" '
    + 'width="250" height="230" name="bcam_video" align="middle"'
    + 'play="true"'
    + 'loop="false"'
    + 'quality="high"'
    + 'allowScriptAccess="sameDomain"'
    + 'type="application/x-shockwave-flash"'
    + 'pluginspage="http://www.macromedia.com/go/getflashplayer">'
    + '<\/embed>'
    + '<\/object>';
    document.write(oeTags);   // embed the flash movie
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here.'
        + 'This content requires the Macromedia Flash Player.'
         + '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
  }
// -->
</script>
<noscript>
      // Provide alternate content for browsers that do not support scripting
      // or for those that have scripting disabled.
        Alternate HTML content should be placed here. This content requires the Macromedia Flash Player.
        <a href="http://www.macromedia.com/go/getflash/">Get Flash</a>        
</noscript>
</body>
</html>
0
Comment
Question by:slovisa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 17944624
1.) File --> Publish Settings --> HTML --> Template --> select "Detect for Flash 6"
0
 
LVL 9

Assisted Solution

by:Jakob_E
Jakob_E earned 250 total points
ID: 17945689
Hi,

Have a look at SWFObject - It does all you want :)
Link:          http://blog.deconcept.com/swfobject/
Download: http://blog.deconcept.com/swfobject/swfobject1-4.zip

Best,
Jakob E

0
 
LVL 4

Author Comment

by:slovisa
ID: 17956009
Dushan, I have tried to publish withe the Detect option checked, but it doesn't accomplish all of the above goals.

Jakob, this sounds like the perfect solution, but I haven't been able to make it work. Maybe I'm over-simplifying it - I simply added this to the header:
<!-- SWFObject embed by Geoff Stearns geoff@deconcept.com http://blog.deconcept.com/swfobject/ -->
<script type="text/javascript" src="swfobject.js"></script>

Then added this where my Flash object goes:
      <div id="flashcontent">
            This content requires the Macromedia Flash Player.<br />
            <a href="http://www.adobe.com/go/getflashplayer">Click here to Get Flash.</a>
      </div>

      <script type="text/javascript">
            // <![CDATA[
            var so = new SWFObject("bcam_video.swf", "bcam_video", "250", "230", "8.0.0", "#FFFFFF", true);
            so.write("flashcontent");
            // ]]>
      </script>

(And of course added the swfobject.js file to my server)

That's not working for me at all. What am I doing wrong?
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 4

Author Comment

by:slovisa
ID: 17962557
If anyone can tell me how to implement SWFObject to:
1) Detect the user's Flash Player version
2) *Express Install/Upgrade* to new version if necessary
3) *Display alternate content* to users who can't Express Install
3) Begin playing the SWF, *including the active content workaround* (no click/space bar to use controls)

The points are all yours. Please help!
0
 
LVL 9

Expert Comment

by:Jakob_E
ID: 17964663
Hmmm

Have you looked at the expressinstall.html and flashversion.html
both included in the zip file... They works on my pc (ie + firefox)

~ Jakob
0
 
LVL 4

Author Comment

by:slovisa
ID: 17966326
Yes. Here's exactly what I've done:

1) Copied to my header:
<script type="text/javascript" src="swfobject.js"></script>


2) Copied to the body, where my swf should appear:
<div id="flashcontent">
This page requires the Macromedia Flash Player.<br>
<a href="http://www.macromedia.com/go/getflash/" target="_blank">Get Flash</a>
</div>
<script type="text/javascript">
   var so = new SWFObject("bcam_video.swf", "bcam_video", "250", "230", "8", "#FFFFFF");
   so.write("flashcontent");
</script>


3) Copied to the first frame of my SWF (no other content on frame 1):
#include "expressinstall.as"

// initialize the ExpressInstall object
var ExpressInstall = new ExpressInstall();

// if the user needs to upgrade, show the 'start upgrade' button
if (ExpressInstall.needsUpdate) {

     // this is optional, you could also automatically start the
     // upgrade by calling ExpressInstall.init() here instead of the following lines

     // attach the custom upgrade message and center it
     var upgradeMsg = attachMovie("upgradeMsg_src", "upgradeMsg", 1);
     upgradeMsg._x = Stage.width / 2;
     upgradeMsg._y = Stage.height / 2;

     // attach the button actions that will start the ExpresInstall updater
     upgradeMsg.upgradeBtn.onRelease = function() {
          // the ExpressInstall.init() method is what kicks off the actual update
          ExpressInstall.init();
     }
     // if expressinstall is invoked, stop the timeline.
     stop();
}


4) Copied expressinstall.as and swfobject.js to my web server.

The results: I get a big blank box in IE6, and I get the alternate content in Firefox - And I have Player9 installed...

Any idea what I'm doing wrong? Thanks for your help.
0
 
LVL 11

Expert Comment

by:ch2
ID: 17994664
try like this. The script must reside inside the flashcontent.

<div id="flashcontent">
This page requires the Macromedia Flash Player.<br>
<a href="http://www.macromedia.com/go/getflash/" target="_blank">Get Flash</a>

<script type="text/javascript">
   var so = new SWFObject("bcam_video.swf", "bcam_video", "250", "230", "8", "#FFFFFF");
   so.write("flashcontent");
</script>
</div>
0
 
LVL 4

Author Comment

by:slovisa
ID: 17995619
The SWFObject embed alone seems to work whether the JS is inside or outside the DIV, since it's targeting the DIV anyway. Adding the Express Install is where I'm running into trouble.
0
 
LVL 11

Expert Comment

by:ch2
ID: 17995742
Well yesterday i installed it following these instructions and it worked out. So should work for you to.

http://blog.deconcept.com/swfobject/#expressinstall
0
 
LVL 11

Accepted Solution

by:
ch2 earned 250 total points
ID: 17995767
Also make sure to read the notes like next one:

It's important to not place any content on the first frame (or wherever your ExpressInstall check happens) that requires Flash player 7 or higher.
0
 
LVL 4

Author Comment

by:slovisa
ID: 18324826
Ultimately the SWFObject solution was implemented correctly, but the swf was missing a stop action on the final frame...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question