changeset 804:0f7b9ac48364

Fix Bug #1500: Error caused by buffer not being loaded into the pool and then not linking once downloaded.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 18 Dec 2015 17:50:14 +0000
parents 947ef5412d22
children 08a3b497d6c4
files ape.js core.js
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ape.js	Fri Dec 18 17:27:52 2015 +0000
+++ b/ape.js	Fri Dec 18 17:50:14 2015 +0000
@@ -330,6 +330,12 @@
 		// Find URL of track
 		// In this jQuery loop, variable 'this' holds the current audioElement.
 		
+		// Check if an outside reference
+		if (index == audioHolderObject.outsideReference)
+		{
+			return;
+		}
+		
 		// Now load each audio sample. First create the new track by passing the full URL
 		var trackURL = audioHolderObject.hostURL + element.url;
 		var audioObject = audioEngineContext.newTrack(element);
@@ -414,7 +420,7 @@
 		outsideReferenceHolderspan.textContent = 'Reference';
 		outsideReferenceHolder.appendChild(outsideReferenceHolderspan);
 		
-		var audioObject = audioEngineContext.newTrack(audioHolderObject.outsideReference);
+		var audioObject = audioEngineContext.newTrack(audioHolderObject.audioElements[audioHolderObject.outsideReference]);
 		
 		outsideReferenceHolder.onclick = function(event)
 		{
--- a/core.js	Fri Dec 18 17:27:52 2015 +0000
+++ b/core.js	Fri Dec 18 17:50:14 2015 +0000
@@ -1932,12 +1932,14 @@
 				this.commentBoxPrefix = "Comment on track";
 			}
 			var audioElementsDOM = xml.getElementsByTagName('audioElements');
+			var outsideReferenceHolder = null;
 			for (var i=0; i<audioElementsDOM.length; i++) {
 				var node = new this.audioElementNode();
 				node.decode(this,audioElementsDOM[i]);
 				if (audioElementsDOM[i].getAttribute('type') == 'outsidereference') {
 					if (this.outsideReference == null) {
-						this.outsideReference = node;
+						outsideReferenceHolder = node;
+						this.outsideReference = i;
 					} else {
 						console.log('Error only one audioelement can be of type outsidereference per audioholder');
 						this.audioElements.push(node);
@@ -1952,6 +1954,12 @@
 			{
 				this.audioElements = randomiseOrder(this.audioElements);
 			}
+			if (outsideReferenceHolder != null)
+			{
+				this.audioElements.push(outsideReferenceHolder);
+				this.outsideReference = this.audioElements.length-1;
+			}
+			
 			
 			var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion');
 			for (var i=0; i<commentQuestionsDOM.length; i++) {