changeset 1190:f0c74260c47d

Discrete / Radio interfaces now have outside-reference support.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 17 Feb 2016 15:09:26 +0000
parents 51d2bd596640
children 3c25db9c8393
files example_eval/radio_example.xml interfaces/discrete.js
diffstat 2 files changed, 69 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/example_eval/radio_example.xml	Wed Feb 17 12:29:22 2016 +0000
+++ b/example_eval/radio_example.xml	Wed Feb 17 15:09:26 2016 +0000
@@ -30,5 +30,6 @@
 		</interface>
 		<audioelement url="0.wav" id="track-1"/>
 		<audioelement url="1.wav" id="track-2"/>
+        <audioelement url="2.wav" id="track-3" type="outside-reference"/>
 	</page>
 </waet>
--- a/interfaces/discrete.js	Wed Feb 17 12:29:22 2016 +0000
+++ b/interfaces/discrete.js	Wed Feb 17 15:09:26 2016 +0000
@@ -380,6 +380,74 @@
 	};
 };
 
+function outsideReferenceDOM(audioObject,index,inject)
+{
+	this.parent = audioObject;
+	this.outsideReferenceHolder = document.createElement('button');
+	this.outsideReferenceHolder.id = 'outside-reference';
+	this.outsideReferenceHolder.className = 'outside-reference';
+	this.outsideReferenceHolder.setAttribute('track-id',index);
+	this.outsideReferenceHolder.textContent = "Play Reference";
+	this.outsideReferenceHolder.disabled = true;
+	
+	this.outsideReferenceHolder.onclick = function(event)
+	{
+        if (event.currentTarget.textContent == "Play Reference") {
+		  audioEngineContext.play(event.currentTarget.getAttribute('track-id'));
+        } else {
+            audioEngineContext.stop();
+        }
+	};
+	inject.appendChild(this.outsideReferenceHolder);
+	this.enable = function()
+	{
+		if (this.parent.state == 1)
+		{
+			this.outsideReferenceHolder.disabled = false;
+		}
+	};
+	this.updateLoading = function(progress)
+	{
+		if (progress != 100)
+		{
+			progress = String(progress);
+			progress = progress.split('.')[0];
+			this.outsideReferenceHolder.textContent = progress+'%';
+		} else {
+			this.outsideReferenceHolder.textContent = "Play Reference";
+		}
+	};
+    this.startPlayback = function()
+    {
+        // Called when playback has begun
+        this.outsideReferenceHolder.style.backgroundColor = "rgb(255,100,100)";
+        this.outsideReferenceHolder.textContent = "Stop";
+    };
+    this.stopPlayback = function()
+    {
+        // Called when playback has stopped. This gets called even if playback never started!
+        $(this.outsideReferenceHolder).removeClass('track-slider-playing');
+        this.outsideReferenceHolder.style.backgroundColor = "";
+        this.outsideReferenceHolder.textContent = "Play Reference";
+    };
+	this.exportXMLDOM = function(audioObject)
+	{
+		return null;
+	};
+	this.getValue = function()
+	{
+		return 0;
+	};
+	this.getPresentedId = function()
+	{
+		return 'reference';
+	};
+	this.canMove = function()
+	{
+		return false;
+	};
+}
+
 function resizeWindow(event)
 {
 	// Called on every window resize event, use this to scale your page properly