detect flash player, then create the HTML

Discussion in 'C#' started by ludwig, Jun 26, 2006.

  1. #1
    Hi guys,

    I am working on my new portal and I want to do something like this

    when you enter I check for a cookie, lets say

    strisFlashPlayerAvailable = Request.Cookies("isFlashPlayerAvailable")
    Code (markup):
    next STEP
    
    if strisFlashPlayerAvailable then
            response.write "<object>......etc"
        else
            [COLOR="Red"]CHECK IF THE FLASH PLAYER EXISTS OR NO[/COLOR]
            response.write "<img>....etc"
    end if
    
    Code (markup):
    I know there should be a small scripts that can do this, but I can't find it in my archives. Can anyone help me with the detection please.

    Thank you in advance.
     
    ludwig, Jun 26, 2006 IP
  2. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    me? i'd probably escape your VB with %> ...<% and just use a plain jane JS flash detector. something like

    
    
    var MM_contentVersion = 6;
    var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
    if ( plugin ) {
    		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
    	    for (var i = 0; i < words.length; ++i)
    	    {
    		if (isNaN(parseInt(words[i])))
    		continue;
    		var MM_PluginVersion = words[i]; 
    	    }
    	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
    }
    else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
       && (navigator.appVersion.indexOf("Win") != -1)) {
    	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
    	document.write('on error resume next \n');
    	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
    	document.write('</SCR' + 'IPT\> \n');
    }
    if ( MM_FlashCanPlay ) {
    document.write('<object type="application/x-shockwave-flash" data="/new1024withoutmarquee.swf" width="510" height="344">');
    	document.write('<param name="movie" value="/new1024withoutmarquee.swf" />');
    	document.write('<param name="quality" value="high" />'); 
    	document.write('<param name="loop" value="2" />'); 
    	document.write('<param name="wmode" value="transparent" />');
    	document.write(' </object>');
    
    } else{
    	document.write('<img src="/new1024.jpg" width="510" height="344" border="0" usemap="#Map">');
    document.write('<map name="Map">');
      document.write('<area shape="rect" coords="1,5,106,110" href="../OPPORTUNITIES/DRIVINGOP.HTML">');
      document.write('<area shape="rect" coords="1,116,106,219" href="/applications/index.html">');
      document.write('<area shape="rect" coords="1,224,107,329" href="/logistics/logistics.html">');
    document.write('</map>');
    }
    
    Code (markup):
    that's one i lifted directly off of one of my sites, basically looks to see if flash is there, if it is, embed the flash movie, if not, display a .jpg with hyperlink hotspots on it. pretty basic stuff, i think there are a hundred different JS flash detection scripts out there. at least 99 anyway.

    I understand that it can be done in VB as well, but thats just the way i've always done it and honestly i never saw the need to re-invent the wheel when c/p'ing JS code into my app worked just fine for me. I just googled and saw some VB examples: here's a couple (no idea if it works)

    http://www.quirksmode.org/js/flash.html

    http://www.adobe.com/devnet/flashplayer/articles/future_detection_03.html

    HTH :D

    VG
     
    vectorgraphx, Jun 27, 2006 IP
  3. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #3
    thanks a lot, currently I am busy, but will go over it in the next couple of days and test all the possible scrips.

    I'll post here the best way, if I find a better one :)

    thanks VC
     
    ludwig, Jun 27, 2006 IP
  4. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    oh i have no doubt that there are better ones out there. that one's kinda old. do post back if you find one that is better - i'm curious.

    lata

    VG
     
    vectorgraphx, Jun 27, 2006 IP