changeset 508:8d01d2bf4b8f Dev_main

Bug #1567: Updated rest of button based interfaces to follow AB playback controls.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 11 Feb 2016 14:22:30 +0000
parents fbba14d4e21c
children e3ff10a1ebc5
files interfaces/discrete.js interfaces/horizontal-sliders.js interfaces/mushra.js
diffstat 3 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/interfaces/discrete.js	Thu Feb 11 14:16:09 2016 +0000
+++ b/interfaces/discrete.js	Thu Feb 11 14:22:30 2016 +0000
@@ -275,11 +275,15 @@
 	this.play.textContent = "Loading...";
 	this.play.value = audioObject.id;
 	this.play.disabled = true;
+    this.play.setAttribute("playstate","ready");
 	this.play.onclick = function(event)
 	{
 		var id = Number(event.currentTarget.value);
 		//audioEngineContext.metric.sliderPlayed(id);
-		audioEngineContext.play(id);
+        if (event.currentTarget.getAttribute("playstate") == "ready")
+            audioEngineContext.play(id);
+        else if (event.currentTarget.getAttribute("playstate") == "playing")
+            audioEngineContext.stop();
 	};
 	this.resize = function(event)
 	{
@@ -323,6 +327,7 @@
     this.startPlayback = function()
     {
         // Called by audioObject when playback begins
+        this.play.setAttribute("playstate","playing");
         $(".track-slider").removeClass('track-slider-playing');
 		$(this.holder).addClass('track-slider-playing');
 		var outsideReference = document.getElementById('outside-reference');
@@ -334,6 +339,7 @@
     this.stopPlayback = function()
     {
         // Called by audioObject when playback stops
+        this.play.setAttribute("playstate","ready");
         $(this.holder).removeClass('track-slider-playing');
         this.play.textContent = "Play";
     }
--- a/interfaces/horizontal-sliders.js	Thu Feb 11 14:16:09 2016 +0000
+++ b/interfaces/horizontal-sliders.js	Thu Feb 11 14:22:30 2016 +0000
@@ -263,11 +263,15 @@
 	this.play.textContent = "Loading...";
 	this.play.value = audioObject.id;
 	this.play.disabled = true;
+    this.play.setAttribute("playstate","ready");
 	this.play.onclick = function(event)
 	{
 		var id = Number(event.currentTarget.value);
 		//audioEngineContext.metric.sliderPlayed(id);
-		audioEngineContext.play(id);
+        if (event.currentTarget.getAttribute("playstate") == "ready")
+        {audioEngineContext.play(id);}
+        else if (event.currentTarget.getAttribute("playstate") == "playing")
+        {audioEngineContext.stop();}
 	};
 	this.resize = function(event)
 	{
@@ -288,6 +292,7 @@
     this.startPlayback = function()
     {
         // Called when playback has begun
+        this.play.setAttribute("playstate","playing");
         $(".track-slider").removeClass('track-slider-playing');
 		$(this.holder).addClass('track-slider-playing');
 		var outsideReference = document.getElementById('outside-reference');
@@ -298,6 +303,7 @@
     this.stopPlayback = function()
     {
         // Called when playback has stopped. This gets called even if playback never started!
+        this.play.setAttribute("playstate","ready");
         $(this.holder).removeClass('track-slider-playing');
     };
 	this.getValue = function()
--- a/interfaces/mushra.js	Thu Feb 11 14:16:09 2016 +0000
+++ b/interfaces/mushra.js	Thu Feb 11 14:22:30 2016 +0000
@@ -269,17 +269,16 @@
 	this.play.style.float = "left";
 	this.play.style.width = "100%";
 	this.play.disabled = true;
+    this.play.setAttribute("playstate","ready");
 	this.play.onclick = function(event)
 	{
 		var id = Number(event.currentTarget.value);
 		//audioEngineContext.metric.sliderPlayed(id);
 		audioEngineContext.play(id);
-		$(".track-slider").removeClass('track-slider-playing');
-		$(event.currentTarget.parentElement).addClass('track-slider-playing');
-		var outsideReference = document.getElementById('outside-reference');
-		if (outsideReference != null) {
-			$(outsideReference).removeClass('track-slider-playing');
-		}
+		if (event.currentTarget.getAttribute("playstate") == "ready")
+        {audioEngineContext.play(id);}
+        else if (event.currentTarget.getAttribute("playstate") == "playing")
+        {audioEngineContext.stop();}
 	};
 	
 	this.enable = function() {
@@ -297,6 +296,7 @@
     this.startPlayback = function()
     {
         // Called when playback has begun
+        this.play.setAttribute("playstate","playing");
         $(".track-slider").removeClass('track-slider-playing');
 		$(this.holder).addClass('track-slider-playing');
 		var outsideReference = document.getElementById('outside-reference');
@@ -307,6 +307,7 @@
     this.stopPlayback = function()
     {
         // Called when playback has stopped. This gets called even if playback never started!
+        this.play.setAttribute("playstate","ready");
         $(this.holder).removeClass('track-slider-playing');
     };
 	this.getValue = function() {