diff core.js @ 770:d2a83474a967

Moved common test options into core.JS
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Mon, 07 Dec 2015 11:18:11 +0000
parents 30adbf6a6d50
children 0796d28701ae
line wrap: on
line diff
--- a/core.js	Mon Dec 07 09:47:26 2015 +0000
+++ b/core.js	Mon Dec 07 11:18:11 2015 +0000
@@ -458,7 +458,7 @@
 				this.currentStateMap = this.stateMap[this.stateIndex];
 				if (this.currentStateMap.type == "audioHolder") {
 					console.log('Loading test page');
-					loadTest(this.currentStateMap);
+					interfaceContext.newPage(this.currentStateMap);
 					this.initialiseInnerState(this.currentStateMap);
 				} else if (this.currentStateMap.type == "pretest" || this.currentStateMap.type == "posttest") {
 					if (this.currentStateMap.options.length >= 1) {
@@ -2000,6 +2000,26 @@
 	this.specification = specificationObject;
 	this.insertPoint = document.getElementById("topLevelBody");
 	
+	this.newPage = function(audioHolderObject)
+	{
+		audioEngineContext.newTestPage();
+		/// CHECK FOR SAMPLE RATE COMPATIBILITY
+		if (audioHolderObject.sampleRate != undefined) {
+			if (Number(audioHolderObject.sampleRate) != audioContext.sampleRate) {
+				var errStr = 'Sample rates do not match! Requested '+Number(audioHolderObject.sampleRate)+', got '+audioContext.sampleRate+'. Please set the sample rate to match before completing this test.';
+				alert(errStr);
+				return;
+			}
+		}
+		
+		audioEngineContext.loopPlayback = audioHolderObject.loop;
+		// Delete any previous audioObjects associated with the audioEngine
+		audioEngineContext.audioObjects = [];
+		interfaceContext.deleteCommentBoxes();
+		interfaceContext.deleteCommentQuestions();
+		loadTest(audioHolderObject);
+	};
+	
 	// Bounded by interface!!
 	// Interface object MUST have an exportXMLDOM method which returns the various DOM levels
 	// For example, APE returns  the slider position normalised in a <value> tag.