Added a stop player function
authorPhilippe Le Hégaret <plh@w3.org>
Fri, 21 Nov 2008 22:35:22 +0000
changeset 19 2f7732216962
parent 18 d96f7e0383b5
child 20 be90f549fcb0
Added a stop player function
testsuite/web-framework/JWP.js
testsuite/web-framework/NCAM.js
testsuite/web-framework/functions.js
--- a/testsuite/web-framework/JWP.js	Fri Nov 21 20:45:59 2008 +0000
+++ b/testsuite/web-framework/JWP.js	Fri Nov 21 22:35:22 2008 +0000
@@ -2,13 +2,15 @@
 
 var JWP_NAME = "JW FLV Media Player 4.2";
 
-addPlayer(JWP_NAME, "startJWPPlayer", "activeJWPTest", "stopJWPPlayer");
+addPlayer(JWP_NAME, "startJWPPlayer", "activeJWPTest", "stopJWPTest", "stopJWPPlayer");
 
 function startJWPPlayer()
 {
-    alert("Note that the "
-	  + JWP_NAME
-	  + " only works properly when accessing captioning files from a web server.");
+    if (document.URL.substring(0, 5) != "http:") {
+	alert("Note that the "
+	      + JWP_NAME
+	      + " only works properly when accessing captioning files from a web server.");
+    }
 }
 
 function activeJWPTest(test_number, filename, autostart, div) 
@@ -36,6 +38,10 @@
     div.appendChild(embed);
 }
 
+function stopJWPTest(test_number) 
+{
+}
+
 function stopJWPPlayer()
 {
     // nothing can be done?
--- a/testsuite/web-framework/NCAM.js	Fri Nov 21 20:45:59 2008 +0000
+++ b/testsuite/web-framework/NCAM.js	Fri Nov 21 22:35:22 2008 +0000
@@ -1,21 +1,14 @@
-// Display a video with the specified DFXP captioning document
-// 1. Create one function with no parameter to start your player.
-// 2. Create a function to activate your player with a test, as follows:
-//    a. the function takes five parameters:
-//       1. integer: The test unique number [inte
-//       2. string: filename of the test
-//       3. boolean: if autostart should be on or off
-//       4. DOM Element: the DOM div element containing your player object
-//    b. the player goes in <div id="testarea">
-// 3. Create one function with no parameter to stop your player.
-// 4. Invoke addPlayer("name of the player", "YourActivateFunctionName", "YourStopFunctionName") to add your player
-
-addPlayer("NCAM Player 3.0.1", "startNCAMPlayer", "activeNCAMTest", "stopNCAMPlayer");
+addPlayer("NCAM Player 3.0.1", 
+	  "startNCAMPlayer", 
+	  "startNCAMTest", 
+	  "stopNCAMTest", 
+	  "stopNCAMPlayer");
 
 function startNCAMPlayer() {
+    // nothing needs to be done
 }
 
-function activeNCAMTest(test_number, filename, autostart, div) {
+function startNCAMTest(test_number, filename, autostart, div) {
 
     var value = "ccPlayer.swf?ccVideoName=dfxp_movie.flv&ccVideoAutoStart="
 		   + autostart
@@ -29,10 +22,10 @@
 	    + 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" type="application/x-shockwave-flash">'
 	    + '<PARAM name="movie" class="object" value="'
 	    + value
-	    + '/><PARAM name="bgcolor" value="#cccccc"/><PARAM name="allowScriptAccess" value="sameDomain"/>'
+	    + '/><PARAM name="bgcolor" value="#cccccc"/><PARAM name="allowScriptAccess" value="always"/>'
 	    + '<EMBED width="340" height="376" src="'
 	    + value
-	    + '" bgcolor="#cccccc" allowscriptaccess="sameDomain" type="application/x-shockwave-flash"/></OBJECT>';
+	    + '" bgcolor="#cccccc" allowscriptaccess="always" type="application/x-shockwave-flash"/></OBJECT>';
     } else {
 	div.innerHTML = '';
 	// Create the object
@@ -70,7 +63,12 @@
 
 }
 
-function stopNCAMPlayer(test_number)
+function stopNCAMTest(test_number)
 {
-    // nothing can be done?
+    // nothing needs to be done
+}
+
+function stopNCAMPlayer()
+{
+    // nothing needs to be done
 }
\ No newline at end of file
--- a/testsuite/web-framework/functions.js	Fri Nov 21 20:45:59 2008 +0000
+++ b/testsuite/web-framework/functions.js	Fri Nov 21 22:35:22 2008 +0000
@@ -71,23 +71,26 @@
 // list of players
 var players = new Array();
 // the player in use
-var player = -1;
+var player = 0;
 var autostart = false;
 
 // A constant to make it easier to access the array
 // var NAME = 0; is already defined
-var START_FUNCTION_NAME = 1;
-var ACTIVATE_FUNCTION_NAME = 2;
-var STOP_FUNCTION_NAME = 3;
+var START_PLAYER_FUNCTION_NAME = 1;
+var START_TEST_FUNCTION_NAME   = 2;
+var STOP_TEST_FUNCTION_NAME    = 3;
+var STOP_PLAYER_FUNCTION_NAME  = 4;
 
 function addPlayer(name,
 		   startFunctionName,
-		   activateFunctionName, 
+		   startTestFunctionName, 
+		   stopTestFunctionName, 
 		   stopFunctionName)
 {
     players[players.length] = new Array(name,
 					startFunctionName,
-					activateFunctionName,
+					startTestFunctionName, 
+					stopTestFunctionName, 
 					stopFunctionName);
 }
 
@@ -105,10 +108,16 @@
     var report_content = document.getElementById("report_content");
     report_content.innerHTML = '';
 
+    if (player > 0) {
+	eval(players[player-1][STOP_PLAYER_FUNCTION_NAME] + "()");
+    }
+
     // switch
     player = nPlayer;
 
-    eval(players[player-1][START_FUNCTION_NAME] + "()");
+    if (player > 0) {
+	eval(players[player-1][START_PLAYER_FUNCTION_NAME] + "()");
+    }
 }
 
 function switchAutostart(nAutostart)
@@ -174,6 +183,8 @@
     var descr=document.getElementById("description");
 
     if (test_number > -1 && test_number < tests.length) {
+	stopTest(currentTest);
+
 	title.innerHTML = tests[test_number][NAME];
 	descr.innerHTML = tests[test_number][DESCRIPTION];
 	if (player == 0) {
@@ -182,7 +193,7 @@
 	} else {
 	    addResultButtons(test_number);
 	    
-	    eval(players[player-1][ACTIVATE_FUNCTION_NAME] + "("
+	    eval(players[player-1][START_TEST_FUNCTION_NAME] + "("
 		 + test_number + ",\""
 		 + tests[test_number][FILE] + "\","
 		 + autostart
@@ -222,7 +233,7 @@
 {
     if (test_number > -1 && test_number < tests.length) {
 	if (player > 0) {
-	    eval(players[player-1][STOP_FUNCTION_NAME] + "("
+	    eval(players[player-1][STOP_TEST_FUNCTION_NAME] + "("
 		 + test_number + ")");
 	    currentTest = -1;
 	}
@@ -371,13 +382,39 @@
 
 function getFlashPlayerVersion()
 {    
-    if (navigator.plugins && navigator.mimeTypes.length) {
+    if (navigator.plugins && navigator.plugins.length) {
         var plugin = navigator.plugins["Shockwave Flash"];
         if (plugin && plugin.description) {
-            return plugin.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".");
+            return plugin.description;
+	} else {
+	    return "no flash";
         }
+    } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
+	var mime = navigator.mimeTypes['application/x-shockwave-flash'];
+	if (mime && mime.enabledPlugin) {
+	    return mime.enabledPlugin.description;
+	} else {
+	    return "no flash";
+	}
+    } else {
+	try {
+	    var obj = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
+	    return obj.GetVariable('$version');
+	} catch (e) {
+	    try {
+		var obj = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
+		return '6.0.21';
+	    } catch (e) {
+		try {
+		    var obj = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
+		    return obj.GetVariable('$version');
+		} catch (e) {
+		    return "no flash";
+		}
+	    }
+	}
     }
-    return [0, 0, 0];
+    return "unknown";
 }
 
 function report()
@@ -427,7 +464,7 @@
     
     var version = getFlashPlayerVersion();
     p = document.createElement("p");
-    p.innerHTML = "Shockwave Flash: " + version[0] + "." + version[1] + " r" + version[2];
+    p.innerHTML = "Shockwave Flash: " + version;
     report_content.appendChild(p);
     
     p = document.createElement("p");