Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Flash Version Detection

20 replies [Last post]

Useing the following script from: http://www.quirksmode.org/js/flash.html

Test on my server: http://www.simplethoughtproductions.com/wp-content/uploads/Other/josh/hd_test/video_test.html

I am trying to see if they have flash 9 or higher to display h264 movies and if not, tell them to update! The script seems to be working fine on both Windows and Macs but I am not sure how to do the final bit of getting the code to be rendered out properly in the document.write and if I am doing the if statement correctly. I have a feeling it is because the script for the video has its own "" and ); which need to be written properly for it to render but I am not sure how to do that. Any help is appreciated.

<SCRIPT LANGUAGE="Javascript">
<!--

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins &amp;&amp; navigator.plugins.length)
{
x = navigator.plugins["Shockwave Flash"];
if (x)
{
flashinstalled = 2;
if (x.description)
{
y = x.description;
flashversion = y.charAt(y.indexOf('.')-1);
}
}
else
flashinstalled = 1;
if (navigator.plugins["Shockwave Flash 2.0"])
{
flashinstalled = 2;
flashversion = 2;
}
}
else if (navigator.mimeTypes &amp;&amp; navigator.mimeTypes.length)
{
x = navigator.mimeTypes['application/x-shockwave-flash'];
if (x &amp;&amp; x.enabledPlugin)
flashinstalled = 2;
else
flashinstalled = 1;
}
else
MSDetect = "true";

// -->
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">

on error resume next

If MSDetect = "true" Then
For i = 2 to 6
If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then

Else
flashinstalled = 2
flashversion = i
End If
Next
End If

If flashinstalled = 0 Then
flashinstalled = 1
End If

</SCRIPT>

<script language="javascript" type="text/javascript">
<!--
if (flashinstalled == 2)
{
if (flashversion >= 9)
document.write("You have Flash version " + flashversion + " installed.");
else
document.write("You have Flash installed, but it is not new enough.");
}
else if (flashinstalled == 1) document.write("You don't have Flash installed.");
else document.write("I can't find out if you have Flash installed.");
// -->
</script>

Found an online converter that converts the HTML to JS so it now works :)

http://www.accessify.com/tools-and-wizards/developer-tools/html-javascript-convertor/default.php

Only issue i have now is that Thick box no longer works with the video in the script and I am not sure why but for most people this solution seems to work just fine... Plus I think IE 7 does not run the script the same as IE 6. Additional testing is needed though :)

Realized I could use the SWFObject! I was doing to much work, using the SWF Object that the player all ready uses with less code!

http://www.simplethoughtproductions.com/wp-content/uploads/Other/josh/hd_test/video_test.html

var version = deconcept.SWFObjectUtil.getPlayerVersion();

is all that is needed and then some if statements. Still playing and testing.

This is cool! I'm thinking of making two or even more versions of each file, one h.264 and one Flash8, so that anyone should be able to watch the best version available with their version of Flash Player (+ perhaps detecting bandwidth for two versions of each format too).

Anyone else who has got this working properly and working with multiple file formats?

Well I have it working with the one so its easy. Just add another IF statment that if it is Below 9.0.100 then write the statement to display the FLV version instead. Keep in mind that JW said he was pllaning to use the adobe feature of falling back to FLV when the player cannot handle MP4. A fall back that is handled internally is always a better option than this JS voodoo but at least it is working now :)

Currently I am using :

if (version['major'] >= 9 && version['rev'] >=115)

technically this will work until they roll out 10.0 (as the rev) will go back to 0, I think I need to make another variable that I add all the numbers to and as long as they are greater than 124 it is good to go... but this is why I am not a programmer. Suggestions?

The fallback option will indeed be there in the 3.14 (released tomorrow). With it, you can assign the H264 file to the "file" flashvar and the FLV to the "fallback" flashvar.

That is good news. Turns out for my new vidcast I will actually only be putting up mp4s. Hopefully this will force a few people to convert ;) But for my sites that need to play for everyone I will def. be using the fall back!

Actually since you give the fall back its own variable they can all fall back to: Get the new thing it rocks... correct?

Correct!

Hmmm... Short Text message saying upgrade or long winded rant by yours truly (me) about the benefits of mp4... which would you rather be put through?

A short mp4-benefit line would be nice though. Then people know why they have to upgrade .. ;)

So I am more of a designer who does some coding. I am not sure if this is possible but I think from this post it is I just don't know how to code it.

I want to use the the FLV Player and have it accessible to people who only have Flash Player version 7 so they DO NOT have to download a New flash player, this would work the same for player 8 users. Users who have player 9+ will get the full loaded player.

I hope this makes sense. Ultimately I don't want the user to have to download a new version of flash. As long as they at least have Flash Player 7 and up they will just see the movie play.

Is there a script to do this or a place to find one?

Using this JW player... what's the easiest way for me to check/tell people that have flash 8 to download version 9?

@Gatti - embed using the swfobject method - please see the following pages:

http://www.jeroenwijering.com/?item=Embedding_Flash
http://www.jeroenwijering.com/?page=wizard

Ok, thanks.

I just realized that the first variable had to be changed from this:
var s1 = new SWFObject("/embed/mediaplayer.swf","mediaplayer","320","240","8");

to this:
var s1 = new SWFObject("/embed/mediaplayer.swf","mediaplayer","320","240","9");

The 8 has to be changed to a 9.

@Gatti - exactly !

> The fallback option will indeed be there in the 3.14 (released tomorrow).
>With it, you can assign the H264 file to the "file" flashvar and the FLV to the "fallback" flashvar.

Yeah, that was cool until v.4.0 arrived. Version 4.0 doesn't support FALLBACK variable :(

That's why I will stay with older player v.3.16.

Why doesn't the player itself detect old versions of flash? A co-worker fired up a new computer today that had flash version 6 and the player displays, but doesn't actually seem to load the skins or play the videos.

How about having the player detect older version of flash and suggest that the user updates?

`flashversion = y.charAt(y.indexOf('.')-1);' returns 0 when Flash 10 is instaled. Any workaround?

Hey Marco,
Try this:

//flashversion = y.charAt(y.indexOf('.')-1);
flashversion = y.slice(15, y.indexOf('.'));

It doesnt display anything if there's no flash installed.
What can i do to fix it? It should display some sort of message to prompt users to download flash

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic).

More information about formatting options