Unity WebPlayer not working on IE 9.0

I had a thread open in Unity Support earlier about this issue too but never got it resolved so just wanted to see if I can get some more help from here :slight_smile:

So to be specific, my Unity WebPlayer game isn’t working at all on IE 9.0 (I get an error which says Data file is currupt(Not a valid Unity Player file)) it bugs out on Forefox 8.0 (Have to refresh like 5 times before the game loads fully).

So this is my code that is on the webpayer.html file:

<?php 

    $app_id = "xxxxxxx";

    $canvas_page = "https://apps.facebook.com/the_rsg/";

    $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
		. $app_id . "&redirect_uri=" . urlencode($canvas_page);

    $signed_request = $_REQUEST["signed_request"];

    list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

    $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

    if (empty($data["user_id"])) {
      echo("<script> top.location.href='" . $auth_url . "'</script>");
    } 
		else {
    	$pageContent = file_get_contents('http://graph.facebook.com/' . $data["user_id"]);
			$parsedJson  = json_decode($pageContent);
       
			$user_id = $parsedJson->id;
			
			$user_name = $parsedJson->name;
     
			session_start();
			$_SESSION['UserID'] = $user_id;
		 
		 }
		 
		 
		//$IDexists = "false";
		
    $db = mysql_connect('localhost', 'xxx', 'xxx') or die('Could not connect: ' . mysql_error()); 
    mysql_select_db('xxx') or die('Could not select database');

    //$hash = $_GET['hash']; 

    //$secretKey="xxx"; # Change this value to match the value stored in the client javascript below 

    //$real_hash = md5($UserID . $Level . $CheckpointsArray . $secretKey); 
    //if($real_hash == $hash) { 
		$query = "SELECT * FROM `RSG_SaveData` ORDER by `UserID` DESC LIMIT 5";
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());
				
		$num_results = mysql_num_rows($result);  

		for($i = 0; $i < $num_results; $i++) {
			$row = mysql_fetch_array($result);
			if ($row['UserID'] == $user_id)	{
				$IDexists = "true";
			}
		}
	
		if ($IDexists == "true")	{
			$IDexists = "true";
		}
		else {
			$IDexists = "false";
		}
		
		if($IDexists == "false") {
      // Send variables for the MySQL database class. 
      $query_third = "INSERT INTO `RSG_SaveData`(`UserID`, `UserName`, `Level`, `CheckpointsArray`) VALUES('$user_id', '$user_name', '$Level', '$CheckpointsArray')"; 
      $result_third = mysql_query($query_third) or die('Query failed: ' . mysql_error()); 
    }
		
		//for($i = 0; $i < $num_results; $i++) {
			//if ($row['UserID'] == 0) {
				//$query_second = "DELETE FROM `RSG_SaveData` WHERE `UserID`=0";
				//$result_second = mysql_query($query_second) or die('Query failed: ' . mysql_error());
			//}
		//}
		//} 

?>


<html>
	
	<head>
		<title>Unity Web Player - webplayer</title>
		<script language='VBScript'>
		function DetectUnityWebPlayerActiveX
			on error resume next
			dim tControl, res, ua, re, matches, major
			res = 0
			set tControl = CreateObject("UnityWebPlayer.UnityWebPlayer.1")
			if IsObject(tControl) then
				if tControl.GetPluginVersion() = "2.5.0f5" then
					' 2.5.0f5 on Vista and later has an auto-update issue
					' on Internet Explorer. Detect Vista (6.0 or later)
					' and in that case treat it as not installed
					ua = Navigator.UserAgent
					set re = new RegExp
					re.Pattern = "Windows NT (\d+)\."
					set matches = re.Execute(ua)
					if matches.Count = 1 then
						major = CInt(matches(0).SubMatches(0))
						if major < 6 then
							res = 1
						end if
					end if
				else
					res = 1
				end if
			end if
			DetectUnityWebPlayerActiveX = res
		end function
		</script>
		<script language="javascript1.1" type="text/javascript">
		
			function GetUnity () {
				if (navigator.appVersion.indexOf("MSIE") != -1  navigator.appVersion.toLowerCase().indexOf("win") != -1)
					return document.getElementById("UnityObject");
				else if (navigator.appVersion.toLowerCase().indexOf("safari") != -1)
					return document.getElementById("UnityObject");
				else
					return document.getElementById("UnityEmbed");
			}
			
			function DetectUnityWebPlayer () {
        		var tInstalled = false;
        		if (navigator.appVersion.indexOf("MSIE") != -1  navigator.appVersion.toLowerCase().indexOf("win") != -1) {
					tInstalled = DetectUnityWebPlayerActiveX();
        		}
        		else {
            		if (navigator.mimeTypes  navigator.mimeTypes["application/vnd.unity"]) {
                		if (navigator.mimeTypes["application/vnd.unity"].enabledPlugin  navigator.plugins  navigator.plugins["Unity Player"]) {
                 			tInstalled = true;	
            			}
         			}	
        		}
        		return tInstalled;	
    		}
    		
    		function GetInstallerPath () {
    			var tDownloadURL = "";
	   			var hasXpi = navigator.userAgent.toLowerCase().indexOf( "firefox" ) != -1;
	   			
    			// Use standalone installer
    			if (1)
    			{
					if (navigator.platform == "MacIntel")
						tDownloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/webplayer-i386.dmg";
					else if (navigator.platform == "MacPPC")
						tDownloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/webplayer-ppc.dmg";
					else if (navigator.platform.toLowerCase().indexOf("win") != -1)
						tDownloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/UnityWebPlayer.exe";
					return tDownloadURL;
    			}
    			// Use XPI installer
				else
				{
					if (navigator.platform == "MacIntel")
						tDownloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/UnityWebPlayerOSX.xpi";
					else if (navigator.platform == "MacPPC")
						tDownloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/UnityWebPlayerOSX.xpi";
					else if (navigator.platform.toLowerCase().indexOf("win") != -1)
						tDownloadURL = "http://webplayer.unity3d.com/download_webplayer-2.x/UnityWebPlayerWin32.xpi";
					return tDownloadURL;
				}    			
    		}
			
			function AutomaticReload () {
				navigator.plugins.refresh();
				if (DetectUnityWebPlayer())
					window.location.reload();

				setTimeout('AutomaticReload()', 500)
			}
			
		</script>
	</head>

	<body>
		<center>
					
			<script language="javascript1.1" type="text/javaScript">
				var hasUnity = DetectUnityWebPlayer();
				var brokenUnity = false;
				if (hasUnity) {
					
					document.write('<object id="UnityObject" classid="clsid:444785F1-DE89-4295-863A-D46C3A781394" width="600" height="450"> \n');
					document.write('  <param name="src" value="webplayer.unity3d" /> \n');
					document.write('  <embed id="UnityEmbed" src="webplayer.unity3d" width="600" height="450" type="application/vnd.unity" pluginspage="http://www.unity3d.com/unity-web-player-2.x" /> \n');
					document.write('</object>');
					
					// if Unity does not define to GetPluginVersion on Safari on 10.6, we presume the plugin
					// failed to load because it is not compatible with 64-bit Safari.
					if (navigator.appVersion.indexOf("Safari") != -1
						 navigator.appVersion.indexOf("Mac OS X 10_6") != -1
						 document.getElementById("UnityEmbed").GetPluginVersion == undefined)
						brokenUnity = true;

					// 2.5.0 cannot auto update on ppc. Treat as broken.
					else if (document.getElementById("UnityEmbed").GetPluginVersion() == "2.5.0f5" 
						 navigator.platform == "MacPPC")
						brokenUnity = true;
				}
				if (!hasUnity || brokenUnity) {
				
					var installerPath = GetInstallerPath();
					if (installerPath != "") {
						// Place a link to the right installer depending on the platform we are on. The iframe is very important! Our goals are:
						// 1. Don't have to popup new page
						// 2. This page still remains active, so our automatic reload script will refresh the page when the plugin is installed
						document.write('<div align="center" id="UnityPrompt"> \n');
						if (brokenUnity)
							document.write('  <a href= ' + installerPath + '><img src="http://webplayer.unity3d.com/installation/getunityrestart.png" border="0"/></a> \n');
						else
							document.write('  <a href= ' + installerPath + '><img src="http://webplayer.unity3d.com/installation/getunity.png" border="0"/></a> \n');
						document.write('</div> \n');
						
						// By default disable ActiveX cab installation, because we can't make a nice Install Now button
//						if (navigator.appVersion.indexOf("MSIE") != -1  navigator.appVersion.toLowerCase().indexOf("win") != -1)
						if (0)
						{	
							document.write('<div id="InnerUnityPrompt"> <p>Title</p>');
							document.write('<p> Contents</p>');
							document.write("</div>");

							var innerUnityPrompt = document.getElementById("InnerUnityPrompt");
							
							var innerHtmlDoc =
								'<object id="UnityInstallerObject" classid="clsid:444785F1-DE89-4295-863A-D46C3A781394" width="320" height="50" codebase="http://webplayer.unity3d.com/download_webplayer-2.x/UnityWebPlayer.cab#version=2,0,0,0">\n' + 
							    '</object>';
							    
							innerUnityPrompt.innerHTML = innerHtmlDoc;
						}

						document.write('<iframe name="InstallerFrame" height="0" width="0" frameborder="0"></iframe>\n');
					}
					else {
						document.write('<div align="center" id="UnityPrompt"> \n');
						if (brokenUnity)
							document.write('  <a href="javascript: window.open("http://www.unity3d.com/unity-web-player-2.x"); "><img src="http://webplayer.unity3d.com/installation/getunityrestart.png" border="0"/></a> \n');
						else
							document.write('  <a href="javascript: window.open("http://www.unity3d.com/unity-web-player-2.x"); "><img src="http://webplayer.unity3d.com/installation/getunity.png" border="0"/></a> \n');
						document.write('</div> \n');
					}
					
					// hide broken player
					if (brokenUnity)
						document.getElementById("UnityEmbed").height = 0;
						
					// Reload when detected unity plugin - but only if no previous plugin is installed 
					// - in that case a browser restart is needed.
					if (!brokenUnity)
						AutomaticReload();
				}
			
			</script>
			<noscript>
				<object id="UnityObject" classid="clsid:444785F1-DE89-4295-863A-D46C3A781394" width="720" height="600" codebase="http://webplayer.unity3d.com/download_webplayer-2.x/UnityWebPlayer.cab#version=2,0,0,0">
					<param name="src" value="webplayer.unity3d" />
					<embed id="UnityEmbed" src="webplayer.unity3d" width="720" height="600" type="application/vnd.unity" pluginspage="http://www.unity3d.com/unity-web-player-2.x" />
					<noembed>
						<div align="center">
							This content requires the Unity Web Player


							<a href="http://www.unity3d.com/unity-web-player-2.x">Install the Unity Web Player today!</a>
						</div>
					</noembed>
				</object>
			</noscript>
			
		</center>
	</body>
	
</html>

The strange thing is, it works fine when I load the game locally from IE but yeah doesn’t work when I upload it try to load it :frowning:

Any help will be greatly appreciated since I really need to get this working! Cheers!

This sucks, it’s like no one has any clue about this :frowning:

Send me a link to your web player game. I will take a look on my end.

Also, just browsing your code, is your request string correctly formed?

Actually I finally figured out that it was a problem with my hosting server, sure is weird.

Thank you so much for replying willing to look at the code!

Cheers mate!

Yeah ever since this f2 f3 crap came out theres been error and i have windows vista. Hopfully the new unity update will fix the problems.

Hey! We’re running into this problem now, too. What was the issue with your hosting server? How did you fix it?

Thanks!

JayShades - do you mind letting us in on what the glitch was?
I’m fighting a losing battle with the crossdomain.xml myself and clutching at straws.

Thanks