diff ape.js @ 135:d769f1623203

Hacky test wait indicator!!
author Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk>
date Thu, 28 May 2015 18:58:45 +0100
parents 2e8500c4df02
children c849dcbe71aa
line wrap: on
line diff
--- a/ape.js	Wed May 27 19:00:20 2015 +0100
+++ b/ape.js	Thu May 28 18:58:45 2015 +0100
@@ -22,6 +22,7 @@
 	// The injection point into the HTML page
 	var insertPoint = document.getElementById("topLevelBody");
 	var testContent = document.createElement('div');
+	
 	testContent.id = 'testContent';
 	
 	
@@ -264,6 +265,8 @@
 	// Load the full interface
 	testState.initialise();
 	testState.advanceState();
+	
+	testWaitIndicator();
 }
 
 function loadTest(textXML)
@@ -443,20 +446,23 @@
 		trackSliderObj.onclick = function() {
 			// Start the test on first click, that way timings are more accurate.
 			audioEngineContext.play();
-			// Get the track ID from the object ID
-			var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
-			//audioEngineContext.metric.sliderPlayed(id);
-			audioEngineContext.selectedTrack(id);
-            // Currently playing track red, rest green
-            document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
-            for (var i = 0; i<$(currentTrackOrder).length; i++)
-            {
-                if (i!=index) // Make all other sliders green
-                {
-                    document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)";
-                }
-                              
-            }
+			if (audioEngineContext.audioObjectsReady) {
+				// Cannot continue to issue play command until audioObjects reported as ready!
+				// Get the track ID from the object ID
+				var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
+				//audioEngineContext.metric.sliderPlayed(id);
+				audioEngineContext.selectedTrack(id);
+	            // Currently playing track red, rest green
+	            document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
+	            for (var i = 0; i<$(currentTrackOrder).length; i++)
+	            {
+	                if (i!=index) // Make all other sliders green
+	                {
+	           	        document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)";
+	                }
+	                              
+	            }
+			}
 		};
 		
 		canvas.appendChild(trackSliderObj);